[Template-haskell] Language.Haskell.THSyntax data types deriving Eq

Ian Lynagh igloo@earth.li
Wed, 13 Aug 2003 01:23:53 +0100


On Wed, Aug 13, 2003 at 12:14:32AM +0100, Alastair Reid wrote:
> On Saturday 09 August 2003 3:58 pm, Andre Pang wrote:
> > Is there a reason why any/all of the data types in
> > Language.Haskell.THSyntax (such as Dec, Stmt, and Type) don't derive
> > Eq?  I'm thinking that it would be useful for test suites, in
> > particular.
> 
> I recently found myself wanting that.
> 
> The tricky one is Eq for types that contain forall. The derived instances 
> would be wrong if we want to allow alpha conversion.

This opens up the issue of how much difference should be allowed in
things before they stop being equal, e.g. should "Let ds1 in e" and
"Let ds2 in e" be equal if they have the same statements in a different
order? What about alpha renaming of variables in expressions? It doesn't
take many acceptable differences before it starts to get rather
complicated, not to mention confusing to the user when some differences
are accepted but others aren't.

I think the best choice is that two datastructures are equal (==) iff
they are identical.

> Hand-writing a correct instance is pretty tedious.

Write it with TH then  :-)


Ian