[Haskell-cafe] Looking for pointfree version

Benja Fallenstein benja.fallenstein at gmail.com
Thu Feb 12 03:19:44 EST 2009

On Thu, Feb 12, 2009 at 8:46 AM, Kim-Ee Yeoh <a.biurvOir4 at asuhan.com> wrote:
> On the same note, does anyone have ideas for the following snippet? Tried the
> pointfree package but the output was useless.
> pointwise op (x0,y0) (x1,y1) = (x0 `op` x1, y0 `op` y1)

import Control.Monad.Reader  -- for the (Monad (a ->)) instance
import Control.Bifunctor  -- package category-extras

dup = join (,)
mapPair = uncurry bimap
pointfree = (mapPair .) . mapPair . dup

Or if you're not afraid of *some* points, and want to avoid the imports:

dup x = (x,x)
mapPair (f,g) (x,y) = (f x, g y)
pointfree op = mapPair . mapPair (dup op)

That what you're looking for? :-)

- Benja

More information about the Haskell-Cafe mailing list