bracketOnError, while, forever

Simon Marlow simonmar at microsoft.com
Tue Mar 15 05:31:53 EST 2005


On 14 March 2005 17:41, Remi Turk wrote:

> 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.

comparing is now available as Data.Ord.comparing, but that doesn't preclude also having a more general combinator.

Personally, I've no doubt that 'on' is useful, but I have reservations about the name.  I don't have any better suggestions, though.

Cheers,
	Simon


More information about the Libraries mailing list