(nie jestem całkowicie zaznajomiony z wewnętrznych mechanizmów przymusu Haskell jest solver więc mogłoby to prawdopodobnie kwestia rekrut.)aplikacje typu i ograniczające rodzaje
Gdy próbuje użyć aplikacji typu na GHC 8.0.1, jak pokazano w poniższym kodzie próbki
{-# LANGUAGE KindSignatures, RankNTypes, ConstraintKinds, ScopedTypeVariables, TypeApplications #-}
module Test where
import Data.Constraint
test0 :: forall (b :: *) . (forall a . a -> Bool) -> b -> Bool
test0 g = g @b
test1 :: forall (c :: * -> Constraint) (b :: *) . (c b) => (forall a . c a => a -> Bool) -> b -> Bool
test1 g = g @b
daje mi następujące błędy
• Could not deduce: c0 b
from the context: c b
bound by the type signature for:
test1 :: c b => (forall a. c a => a -> Bool) -> b -> Bool
at Test.hs:9:10-101
• In the ambiguity check for ‘test1’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature:
test1 :: forall (c :: * -> Constraint) (b :: *).
(c b) => (forall a. c a => a -> Bool) -> b -> Bool
i
• Could not deduce: c a
from the context: c b
bound by the type signature for:
test1 :: c b => (forall a. c a => a -> Bool) -> b -> Bool
at Test.hs:9:10-101
or from: c0 a
bound by the type signature for:
test1 :: c0 a => a -> Bool
at Test.hs:9:10-101
• In the ambiguity check for ‘test1’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature:
test1 :: forall (c :: * -> Constraint) (b :: *).
(c b) => (forall a. c a => a -> Bool) -> b -> Bool
test0
działa tam, gdzie nie ma żadnych ograniczeń, ale test1
nie.