
On 09 February 2005 12:00, Ross Paterson wrote:
On Wed, Feb 09, 2005 at 11:50:48AM -0000, Simon Marlow wrote:
On 08 February 2005 12:33, Thomas Jäger wrote:
First of all
-- Cale Gibbard comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering comparing p x y = compare (p x) (p y) fits nicely with the ...By functions from Data.List.
sortBy (comparing fst)
is just too cute not to have. Any objections?
only that it's not clear where to put it.
Just attempting to empty my inbox... we never resolved this one. Perhaps there should be Data.Ord (and Data.Eq for that matter), and then we'd have an obvious place to put comparing? Cheers, Simon

"Simon Marlow"
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering comparing p x y = compare (p x) (p y)
sortBy (comparing fst)
is just too cute not to have. Any objections?
Just attempting to empty my inbox... we never resolved this one. Perhaps there should be Data.Ord (and Data.Eq for that matter), and then we'd have an obvious place to put comparing?
Seems OK to me. I couldn't find an existing definition of the Eq or Ord class anywhere in the base package - is it currently only in the haskell98 Prelude? Regards, Malcolm

On Mon, Mar 14, 2005 at 11:56:16AM +0000, Malcolm Wallace wrote:
I couldn't find an existing definition of the Eq or Ord class anywhere in the base package - is it currently only in the haskell98 Prelude?
It is currently only in the Prelude, which is in the base package (like Numeric and Foreign).

On Mon, Mar 14, 2005 at 11:39:55AM -0000, Simon Marlow wrote:
On 09 February 2005 12:00, Ross Paterson wrote:
On Wed, Feb 09, 2005 at 11:50:48AM -0000, Simon Marlow wrote:
On 08 February 2005 12:33, Thomas Jäger wrote:
First of all
-- Cale Gibbard comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering comparing p x y = compare (p x) (p y) fits nicely with the ...By functions from Data.List.
sortBy (comparing fst)
is just too cute not to have. Any objections?
only that it's not clear where to put it.
Just attempting to empty my inbox... we never resolved this one. Perhaps there should be Data.Ord (and Data.Eq for that matter), and then we'd have an obvious place to put comparing?
Cheers, Simon
Some people (no idea how many, though at least 1 ;) seem to prefer something like this: cmp `on` conv = \x y -> conv x `cmp` conv y sortBy (compare `on` fst) groupBy ((==) `on` isSpace) though some people (at least Henning Thielemann) prefer to call it compose2. http://www.haskell.org/hawiki/ThingsToAvoid http://www.haskell.org/hawiki/ThingsToAvoid_2fDiscussion contains some discussion about it. Groeten, Remi -- Nobody can be exactly like me. Even I have trouble doing it.

On Mon, 14 Mar 2005, Remi Turk wrote:
On Mon, Mar 14, 2005 at 11:39:55AM -0000, Simon Marlow wrote:
Just attempting to empty my inbox... we never resolved this one. Perhaps there should be Data.Ord (and Data.Eq for that matter), and then we'd have an obvious place to put comparing?
Cheers, Simon
Some people (no idea how many, though at least 1 ;) seem to prefer something like this:
cmp `on` conv = \x y -> conv x `cmp` conv y
sortBy (compare `on` fst) groupBy ((==) `on` isSpace)
though some people (at least Henning Thielemann) prefer to call it compose2.
http://www.haskell.org/hawiki/ThingsToAvoid http://www.haskell.org/hawiki/ThingsToAvoid_2fDiscussion contains some discussion about it.
I won't defend 'compose2' if you dislike it, :-) but I wanted something more specific than 'on' and I didn't see the need for an infix notation.
participants (5)
-
Henning Thielemann
-
Malcolm Wallace
-
Remi Turk
-
Ross Paterson
-
Simon Marlow