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

Sean Seefried sseefried@cse.unsw.EDU.AU
Wed, 13 Aug 2003 10:37:05 +1000 (EST)


On Wed, 13 Aug 2003, Ian Lynagh wrote:

> 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.

That's certainly the simplest solution but I'm not convinced it's the
best. Couldn't you simply write a "canonical-ise" function which takes an
expression and puts it into some sort of canonical form and then tests for
equality. However, there are many issues to consider like you said.
Eta-reduction would another to think about.

Sean