[Haskell-cafe] Distributing monadic(?) functions across dyadic
functions
Nils Anders Danielsson
nad at cs.chalmers.se
Mon Apr 3 05:53:40 EDT 2006
On Sun, 02 Apr 2006, "Jared Updike" <jupdike at gmail.com> wrote:
> Something like "distribute fst (==)" where
>
>> distribute f op x y = f x `op` f y
A function like this has been suggested for the standard libraries a
couple of times before. Someone suggested the name "on", which I quite
like:
(*) `on` f = \x y -> f x * f y
>> unionBy (distribute fst (==)) listOfPairs1 listOfPairs2
unionBy ((==) `on` fst) xs ys
I think on makes the code rather readable: union by equality on first.
--
/NAD
More information about the Haskell-Cafe
mailing list