[Haskell-cafe] RE: [Haskell] boilerplate boilerplate

Alex Jacobson alex at alexjacobson.com
Fri Jun 1 07:41:32 EDT 2007


Claus Reinke wrote:
>> Actually, standalone deriving doesn't really solve the boilerplate 
>> boilerplate problem.  My original complaint here is that I don't want 
>> to explicitly declare a deriving (Data,Typeable) for every type used 
>> somewhere inside a larger type I am using.  In this particular case, 
>> I am using SYB to autogenerate/autoparse XML.  The Atom/RSS datatype 
>> has a lot of elements in it.  Having to do an explicit declaration of 
>> deriving (Data,Typeable) for each of them is just a tremendous 
>> beat-down no matter where I do it.
>>
>> A simple solution to the problem is just to have the compiler 
>> automatically derive Data and Typeable for all classes. 
>
> it still sounds as if you might want to follow Neil's suggestions 
> about using
> Data.Derive, which does seem to have a derive-this-for-all feature.
>
The problem with Data.Derive is that I now have a pre-processor cycle as 
part of my build process. Automatic and universal Data and Typeable 
instance deriving should just be built into Haskell.  I totally agree 
that, if you don't have this deriving by default, it is totally useful 
to be able to derive in a location different from where the type is 
declared, but that is a separate issue.  My main point is that Data and 
Typeable should always be there without extra futzing on the part of the 
programmer.

Speaking of which, any thoughts on fixing my SYB code in the other thread?

-Alex-



More information about the Haskell-Cafe mailing list