<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello Cafe,</div><div><br></div><div>I was trying to load a module containing this function in ghci:<br>"add x y = wrap $ unwrap x + unwrap y"<br></div><div>with the following extensions activated:</div><div><br></div><div>ConstraintKinds<br>DataKinds<br>DeriveFunctor<br>DuplicateRecordFields<br>FlexibleContexts<br>FlexibleInstances<br>GADTs<br>KindSignatures<br>MultiParamTypeClasses<br>PolyKinds<br>TypeFamilies<br>TypeOperators<br>AllowAmbiguousTypes<br></div><div><br></div><div>And it loaded without problem.</div><div><br></div><div>So then I tested its type with ":t add", which gave:</div><div>add :: (Num a, Newtype a b1, Newtype a b2, Newtype a b3) => b2 -> b3 -> b1</div><div><br></div><div>Then I added this signature to the function in the module. This caused ghci</div><div>to refuse to load it and give the following error:</div><div><br></div><div>src/Exercises.hs:55:11: error:<br>    • Could not deduce (Newtype Integer b1)<br>        arising from a use of ‘wrap’<br>      from the context: (Num a, Newtype a b1, Newtype a b2, Newtype a b3)<br>        bound by the type signature for:<br>                   add :: forall a b1 b2 b3.<br>                          (Num a, Newtype a b1, Newtype a b2, Newtype a b3) =><br>                          b2 -> b3 -> b1<br>        at src/Exercises.hs:54:1-74<br>    • In the expression: wrap $ unwrap x + unwrap y<br>      In an equation for ‘add’: add x y = wrap $ unwrap x + unwrap y<br>   |<br>55 | add x y = wrap $ unwrap x + unwrap y<br>   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^<br><br>src/Exercises.hs:55:18: error:<br>    • Could not deduce (Newtype Integer b2)<br>        arising from a use of ‘unwrap’<br>      from the context: (Num a, Newtype a b1, Newtype a b2, Newtype a b3)<br>        bound by the type signature for:<br>                   add :: forall a b1 b2 b3.<br>                          (Num a, Newtype a b1, Newtype a b2, Newtype a b3) =><br>                          b2 -> b3 -> b1<br>        at src/Exercises.hs:54:1-74<br>    • In the first argument of ‘(+)’, namely ‘unwrap x’<br>      In the second argument of ‘($)’, namely ‘unwrap x + unwrap y’<br>      In the expression: wrap $ unwrap x + unwrap y<br>   |<br>55 | add x y = wrap $ unwrap x + unwrap y<br>   |                  ^^^^^^^^<br><br>src/Exercises.hs:55:29: error:<br>    • Could not deduce (Newtype Integer b3)<br>        arising from a use of ‘unwrap’<br>      from the context: (Num a, Newtype a b1, Newtype a b2, Newtype a b3)<br>        bound by the type signature for:<br>                   add :: forall a b1 b2 b3.<br>                          (Num a, Newtype a b1, Newtype a b2, Newtype a b3) =><br>                          b2 -> b3 -> b1<br>        at src/Exercises.hs:54:1-74<br>    • In the second argument of ‘(+)’, namely ‘unwrap y’<br>      In the second argument of ‘($)’, namely ‘unwrap x + unwrap y’<br>      In the expression: wrap $ unwrap x + unwrap y<br>   |<br>55 | add x y = wrap $ unwrap x + unwrap y<br>   |                             ^^^^^^^^<br>Failed, no modules loaded.</div><div><br></div><div>This does not make sense to me, since I only used the signature that ghci itself gave me.</div><div><br></div><div>Is this a bug? if not, could someone please explain this behaviour to me?</div><div><br></div>Thanks,<div>Michel<br></div></div></div></div></div>