[Haskell-cafe] Re: Justification for Ord inheriting from Eq?
ihope
ihope127 at gmail.com
Fri Apr 7 22:12:02 EDT 2006
On 4/7/06, Jared Updike <jupdike at gmail.com> wrote:
> > 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
Both work the same. Here's an intermediate form:
a == b =
if compare a b == EQ
then True
else False
More information about the Haskell-Cafe
mailing list