Hello,
The following piece of code was rejected by Hugs:
> class Foo a where
> write :: a -> String
> write _ = "I'm a foo!"
>
> data Foo a => FooType a = FooType a
>
> writeFoo :: FooType a -> String
> writeFoo (FooType a) = write a
ERROR "Test.hs" (line xx): Cannot justify constraints in explicitly
typed binding
*** Expression : writeFoo
*** Type : FooType a -> String
*** Given context : ()
*** Constraints : Foo a
By changing the type signature for writeFoo to:
> writeFoo :: Foo a => FooType a -> String
or just deleting the signature, I could get it compile. What I don't
understand is, since the constraint "Foo a" is redundant here (Hugs
should be able to figure it out from the line "data Foo a => FooType a =
FooType a"), why doesn't Hugs allow it to be omitted? After all, there
could not really be any "FooType a" where a is *not* an instance of
Foo. Could anybody shed a light on this? Thanks.
-- Zhanyong Wan