[Haskell-cafe] What's the difference?
Paul Johnson
paul at cogito.org.uk
Tue Apr 8 12:43:16 EDT 2008
PR Stanley wrote:
> Hi
> What is the difference between
>
> data T0 f a = MkT0 a
> instance Eq (T0 f a) where ...
>
> and
>
> data T0 f a = MkT0 a
> instance Eq a => Eq (T0 f a) where ...
>
The second one says that "TO f a" is only an instance of "Eq" if "a" is,
while the first says that "TO f a" is an instance regardless of the type
of its arguments.
You can regard an "instance" declaration as an inference rule for the
type checker, with "=>" meaning "implies" (though I don't think its the
answer to your other question about names).
More information about the Haskell-Cafe
mailing list