bracketOnError, while, forever

Mike Gunter m at ryangunter.com
Wed Feb 9 13:27:58 EST 2005



"Simon Marlow" <simonmar at microsoft.com> writes:

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

No objection.  My version of this is defined in terms of another
function which I use directly almost as often,

    onField :: (fv -> fv -> r) -> (s -> fv) -> s -> s -> r
    onField op field r1 r2 = field r1 `op` field r2

, which I consider a good candidate for inclusion in a library.  (I
expect there's a better name, though.)

	mike





More information about the Libraries mailing list