Derivable type classes

Simon Peyton-Jones simonpj@microsoft.com
Wed, 16 Apr 2003 13:06:41 +0100


Gentle GHC users

I'm thinking of removing the "Derivable type classes" stuff from GHC.
It's described in a paper that Ralph Hinze and I wrote
	http://research.microsoft.com/~simonpj/Papers/derive.htm
and in the GHC user manual at
=09
http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-classes.
html

But it's quite complicated to implement, it's incomplete (needs
constructor-name stuff, and better lifting), and it sometimes gives huge
types in the intermediate language (because of the encoding into
tuples).  So the benefit-to-cost ratio seems poor.

Instead, I'm planning to implement the "Scrap your boilerplate" ideas
for generic programming, described in another paper
	http://research.microsoft.com/~simonpj/papers/hmap/
The plan would be to automatically derive classes 'Typable' and 'Term'
for every data type, and make TypeReps a bit more efficient and clean.

Now, I could add the latter without removing the former, but GHC is big
and fat enough already.  So this message is really to ask

	is anyone actually using the derivable-type-class stuff?
	does anyone mind if they die

Speak now or forever hold your peace.

Simon


Just to remind you, derivable type classes let you write definitions
like
  class Eq t where
    (=3D=3D), (/=3D)				:: t -> t -> Bool
=20
    -- generic default method
    (=3D=3D){1}     Unit        Unit	=3D  True
    (=3D=3D){a + b} (Inl x1)    (Inl  x2)	=3D  x1 =3D=3D x2
    (=3D=3D){a + b} (Inr y1)    (Inr y2)	=3D  y1 =3D=3D y2
    (=3D=3D){a + b} _           _		=3D  False
    (=3D=3D){a * b} (x1 :*: y1) (x2 :*: y2)	=3D  x1 =3D=3D x2 && y1 =
=3D=3D y2
=20