{-
This works as expected ... until you uncomment the second asFunction ! This is actually just a built-in version of the special case in which the other two templates already match, so I expect that everything will be alright. But ( ghc-7.6.2 , or also ghc-7.4.1 )
Could not deduce (f ~ f1) from the context (b1 ~ f a1, b ~ f b2, Functor f) bound by a pattern with constructor FMap :: forall (f :: * -> *) a b. Functor f => (a -> b) -> Foo (fa) (fb), in an equation for \`asFunction' ...
Why is this happening, and why then not in other articles? What exactly needs to be done to prevent this problem in more complex applications?
haskell typechecking gadt unification
leftaroundabout
source share