On 8 Apr 2008, at 17:03, Christian Maeder wrote:
"deriving Eq" i.e. following "data List a = List a" creates an instance
like:

 instance Eq a => Eq (List a) where <compiler implementation>

The problem was discussed for Stand-alone deriving declarations:

http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html

There is a difference between
  data Foo a = Bar a | Baz String
  deriving instance Eq a => Eq (Foo a)
and
  data Eq a => Foo a = Bar a | Baz String deriving (Eq)

The second is more restrictive, as it requires Eq for the construction of Foo a, whereas the first could be construed to mean that Eq a is only required for the construction of Eq(Foo a). So the first could be used without Eq a if Eq(Foo a) is not needed. This is good when constructing libraries for general types.

  Hans



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to