[Haskell-cafe] Re: Implementing "unionAll"

Evan Laforge qdunkan at gmail.com
Thu Feb 18 03:07:09 EST 2010


BTW, I notice that your merges, like mine, are left-biased.  This is a
useful property (my callers require it), and doesn't seem to cost
anything to implement, so maybe you could commit to it in the
documentation?

By left-biased I mean that when elements compare equal, pick the
leftmost one, e.g. "mergeOn fst [(0, 'a')] [(0, 'b')] == [(0, 'a'),
(0, 'b')]".

And BTW again, here's something I've occasionally found useful:

-- | Handy to merge or sort a descending list.
reverse_compare :: (Ord a) => a -> a -> Ordering
reverse_compare a b = case compare a b of
    LT -> GT
    EQ -> EQ
    GT -> LT


More information about the Haskell-Cafe mailing list