
Benja Fallenstein wrote:
Kim-Ee Yeoh 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? :-)
The pairs are of course an applicative functor (<*>) = uncurry (***) -- from Control.Arrow pure x = (x,x) pointwise op x y = pure op <*> x <*> y Regards, apfelmus -- http://apfelmus.nfshost.com