[Haskell] recursive deriving

Alex Jacobson alex at alexjacobson.com
Tue Nov 20 19:18:22 EST 2007

When you want automated deriving of show/read etc., you need all the 
components of your type also to be instances of show/read but you won't 
want to *require* them to be automatically generated verions.

Standalone deriving does the wrong thing here.  Standalone deriving 
should not cause an overlapping instance error if someone derives an 
instance manually.  Instead, the manually derived instance should be 
treated as more specific and win out.

The other part of this problem is that you can't do automatic recursive 
deriving and this results in a ridiculous amount of boilerplate.  I know 
some people have a theory that they want to avoid accidentally creating 
instances for things that shouldn't have them, but the solution to that 
is probably to add some declaration for types that prohibits automatic 
deriving for those types.  The 99% case is that automatic deriving is ok.

Proposed syntax:

   derive instance Show T recursively
   data T = T no-deriving (Ord,Eq)


More information about the Haskell mailing list