[Haskell-cafe] 'data' syntax - a suggestion

ok ok at cs.otago.ac.nz
Thu Sep 27 02:09:14 EDT 2007

I have often found myself wishing for a small extension to the syntax of
Haskell 'data' declarations.  It goes like this:

	data <as usual>
	   = <as usual>
	   | ...
	   | <as usual>
+++	   where type <tvar> = <type>
		 type <tvar> = <type>
	   deriving <as usual>

Even something like binary search trees would, to me, be clearer as

	data BST key val
	   = Empty
	   | Fork key val bst bst
	   where type bst = BST key val

because this establishes an *essential* identity between the 3rd and 4th
Fork argument types, rather than an "accidental" identity.  I can't set
this up using 'type' outside the 'data' declaration, because it has to
refer to the type arguments of BST.

Semantically, this is just an abbreviation mechanism with no  
of any kind outside the 'data' declaration itself.  The only point would
be to make reading and writing 'data' declarations easier, especially
large ones.

More information about the Haskell-Cafe mailing list