[Haskell-cafe] Re: deriving

2008-04-08 Thread Christian Maeder
Anton van Straaten wrote:
 How about making deriving x an expression which means:
 
   instance x where compiler implementation

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

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


Re: [Haskell-cafe] Re: deriving

2008-04-08 Thread Hans Aberg

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