Ambiguous uses of multi-param type classes are sometimes silently turned
into Void instances, instead of giving an error message.

Take this class declaration (please!)

> class Collection c a where
>     empty :: c a
>     add :: a -> c a -> c a
>     isempty :: c a -> Bool

> singleton x = add x empty

If I try to compile the following ambiguous program, I get the expected
error message.  (Yes I know it's a peculiar way to write `False' ;-)

> q = isempty . singleton

% ghc -fglasgow-exts  -c t.hs

    Cannot resolve the ambiguous context (Collection aun aum)
        `Collection aun aum' arising from use of `isempty' at t.hs:10

However, if I try to compile the following, it works, much to my surprise.

> q' x = isempty (singleton x)

Here's the .hi line:

1 q' _:_ _forall_ [a] {Collection PrelGHC.Void a} => a -> PrelBase.Bool ;;

If I remove `a' as a parameter of the class, I get the error message
in both cases.

--Jeff

Reply via email to