Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if we derive Ord but not Eq while making a data type?

Tags:

haskell

I understand that in haskell if we make a data type deriving Ord it should be deriving Eq as well, but why do we have to explicitly write both of them in the definition?

like image 902
Prashant Solanki Avatar asked Dec 12 '25 07:12

Prashant Solanki


1 Answers

One could plausibly derive Ord but instantiate Eq by hand:

data Foo = Foo deriving Ord
instance Eq Foo where
    _ == _ = True

I can't think of a place off-hand where this would be useful, but there's no reason to prevent it.

like image 157
Daniel Wagner Avatar answered Dec 14 '25 02:12

Daniel Wagner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!