[Haskell-cafe] Re: Justification for Ord inheriting from Eq?

Jared Updike jupdike at gmail.com
Fri Apr 7 12:47:26 EDT 2006


> given an Ord instance (for a type T) a corresponding Eq instance can be
> given by:
>
> instance Eq T where
>     a == b = compare a b == EQ

where did this second -----^ == come from? (I guess if if Ordering
derives Eq :-) I think you meant

> instance (Ord T) => Eq T where
>     a == b = case compare a b of
>                     EQ -> True
>                     _ -> False

Cheers,
  Jared.

--
http://www.updike.org/~jared/
reverse ")-:"


More information about the Haskell-Cafe mailing list