[Haskell-cafe] deriving

Hans Aberg haberg at math.su.se
Mon Apr 7 15:42:16 EDT 2008


On 7 Apr 2008, at 21:15, Dan Weston wrote:
> To answer your second question (which everyone else ignored):
>
> Yes. A different keyword might have been more descriptive, such as  
> "automatically_deriving_instances_for".

They are called instantiations, which Haskell can supply  
automatically in some cases. And there is already a keyword  
"instance" for that - in general, it is good to keep down the number  
of keywords. So
   data Bool = False | True
     instance (Eq, Ord, Enum, Read, Show, Bounded)
might have been better.

But here, one would have to think about how the compiler should be  
able to distinguish
   data Bool = False | True
     instance (Eq)
from
   data Bool = False | True

   instance Eq Bool where
     x == y = ...
One wants to be able to do that with as little lookahead as possible.

   Hans Aberg




More information about the Haskell-Cafe mailing list