[clean-list] no deriving Eq in Clean? (!)
Ben Lippmeier
Ben.Lippmeier@anu.edu.au
Wed, 07 Jul 2004 15:23:45 +1000
Cleaners,
I can live without deriving Read, Show... but not being able to derive
Eq / == is a real hassle.
If I have a large ADT defined like:
data Cond
= Friend
| Foe
| FriendWithFood
| FoeWithFood
| Food
| Rock
| FoeMarker
| Home
| FoeHome
Is there a better way to define == than:
instance == Cond
where
(==) :: Cond Cond -> Bool
(==) Friend Friend = True
(==) Foe Foe = True
...
(==) _ _ = False
???
Even good old C will do this much for you.
It's even worse if the constructors have an airity more than 0.
I could find no mention of Clean giving you any 'free' functions for
ADTs anywhere in the Clean language report.
I see in Clean2.1Sources/Compiler/frontend/StdCompare.icl that someone
has done basically what I had to do.. If no one has made a move on
deriving Eq since this source was written then somone should probably
add it to the Clean wish list.
Cheers,
Ben.
BTW: There are typos in the page names at
http://www.cs.kun.nl/~clean/CleanExtra/report20/contents.html
http://www.cs.kun.nl/~clean/CleanExtra/report20/chapters.html