Types and types of restrictions

(I am not completely familiar with the internal workings of the Haskell constraint resolver, so this may be a rookie question.)

When trying to use a type application in GHC 8.0.1, as shown in the following code example

{-# 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 :: *) . (cb) => (forall a . ca => a -> Bool) -> b -> Bool test1 g = g @b 

he gives me the following errors

 • Could not deduce: c0 b from the context: cb bound by the type signature for: test1 :: cb => (forall a. ca => 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 :: *). (cb) => (forall a. ca => a -> Bool) -> b -> Bool 

and

 • Could not deduce: ca from the context: cb bound by the type signature for: test1 :: cb => (forall a. ca => 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 :: *). (cb) => (forall a. ca => a -> Bool) -> b -> Bool 

test0 works where there are no restrictions, but test1 does not work.

+7
haskell
source share

All Articles