15 Feb
2006
15 Feb
'06
12:48 p.m.
Christian Maeder wrote:
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
That works, but... Constructing the new tuples is usually more heap allocation, and these short lived data items can make the garbage collection load higher. The `mappend` method avoids this pitfall.