[clean-list] How can I define an equality test ?

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Sun Nov 25 23:13:05 MET 2007


Ferreira Maurizio writes: 

> Im trying to define the == operator
> with  an algebraic data type.
> How can I define it ?

> instance == Day
> where
>   (==) :: Day Day -> Bool
>   (==) x y = x ????? y   ////  what have I to write ?

Unless I am wrong, you cannot count on any intelligence of the compiler... 

(==) Monday Monday = True
(==) Tuesday Tuesday = True
...
(==) _ _ = False   // otherwise 

Jerzy Karczmarczuk 




More information about the clean-list mailing list