With functional dependencies, I can declare the Foo
class:
class Foo a b c | a -> b where
foo1 :: a -> b -> c
foo2 :: a -> c
and when I call foo2
, everything works fine. The compiler knows which instance to use because of the dependency.
But if I remove the dependency to create Foo'
:
class Foo' a b c where
foo1' :: a -> b -> c
foo2' :: a -> c
everything still compiles fine, but now whenever I try to call foo2'
GHC throws an error about not being able to resolve which instance to use because b
is ambiguous.
Is it ever possible to call foo2'
without error? If so, how? If not, why doesn't it generate a compilation error?