[Haskell-cafe] Distributing monadic(?) functions across dyadic functions

Jared Updike jupdike at gmail.com
Sun Apr 2 14:58:31 EDT 2006

Is there a common way (standard libs, higher order) to express the
lambda part below? It's not particulary complicated but I think it is
not higher-order enough

> unionBy (\x y -> fst x == fst y) listOfPairs1 listOfPairs2

Something like "distribute fst (==)" where

> distribute f op x y = f x `op` f y

would leave

> unionBy (distribute fst (==)) listOfPairs1 listOfPairs2

I imagine something involving Arrows and/or zip/curry/uncurry but I just
can't see it. Is this a case of trying to make something more complicated
than it is?

reverse ")-:"

More information about the Haskell-Cafe mailing list