
24 Apr
2009
24 Apr
'09
5:22 p.m.
Hi Denis, Denis Bueno wrote:
where the rCompare field would be a function that is based on the flags passed to the command-line problem. But this has an ugly asymmetry. Does anyone have any other ideas?
Here's a solution that is more symmetrical but not necessarily prettier: newtype Wrap = Wrap { unwrap :: Record } instance Ord Wrap where ... your compare function here ... But I don't think there's anything wrong with your original solution. You can write your own sortBy and hide (not export) the CompareRecord type: sortBy :: (a -> a -> Ord) -> [a] -> IO [a] sortBy cmp = map unCR . sort . map (CompareRecord cmp) HTH, Martijn.