[Haskell] Re: compares :: Ord a => a -> a -> Ordering -> Ordering
Christian Maeder
maeder at tzi.de
Wed Feb 15 06:53:24 EST 2006
Ben Rudiak-Gould wrote:
> I just realized that the class Ord should have an additional method:
>
> class Eq a => Ord a where
> compares :: a -> a -> Ordering -> Ordering
> compares x y d = case compare x y of { EQ -> d ; o -> o }
> ...
How about:
instance (Ord a, Ord b, Ord c, Ord d) => Ord (a,b,c,d) where
compare (a1,b1,c1,d1) (a2,b2,c2,d2) =
compare ((a1,b1,c1),d1) ((a2,b2,c2),d2)
or another tuple nesting)
Christian
More information about the Haskell
mailing list