[Haskell-cafe] New Eq instance

Jules Bean jules at jellybean.co.uk
Thu Aug 9 10:34:02 EDT 2007


rodrigo.bonifacio wrote:
> 
> instance Eq Step where 
>   Step id1 scenario1 action1 state1 response1 == Step id2 scenario2 action2 state2 response2 = id == id
>   _ == _ = False

Almost. You just used 'id' and 'id' when you meant 'id1' and 'id2'.

 > instance Eq Step where
 >   Step id1 scenario1 action1 state1 response1 == Step id2 scenario2 
action2 state2 response2 = id1 == id2

but it's a common idiom not to bother to name unused parameters, so:

 > instance Eq Step where
 >   Step id1 _ _ _ _ == Step id2 _ _ _ _ = id1 == id2

(and the default case is never reached so you don't need it)

>  
> ps.: sorry, this kind of basic question can be sent to this list?


Yes, that's fine.
You may get quicker answers if you hop onto IRC at #haskell, though.

Jules



More information about the Haskell-Cafe mailing list