[Hs-Generics] Re: Scrap your boilerplate and Variants

oleg at pobox.com oleg at pobox.com
Tue Oct 24 23:28:24 EDT 2006


I have just committed the code for the alternative formulation of
SYB3. It requires neither higher-rank types nor mutually recursive
instances. Therefore, the code works even in Hugs (the original SYB3
code does not work in Hugs). The files are in the directory
SYB31/. The `final' code is dat2.hs (dat1.hs is the `intermediate'
step, which makes it easy to understand `dat2.hs'). The code has
comments that describe which part of the code is the `Library', which
part of the code is the `generic function' (independent of the data
structure), and which part of the code overrides some general
processing of the generic function. The code has two examples; one of
them is gsize, from the original SYB3 paper.

I'd like to suggest two corrections to the SyB page:
	first, rank-2 types are not necessarily required for all
flavors of SYB

	second, the original SYB3 imposes one more requirement:
mutually recursive instances. It is rarely mentioned -- but not
universally implemented (Hugs does not have it). SYB31 shows that one
can get by without that requirement. At the ICFP05 talk, Simon
Peyton-Jones asserted that recursive instances are essential. I have
publicly expressed doubts. Simon Peyton-Jones said: if you think
otherwise, show me the code. And so I did.



More information about the Generics mailing list