[Haskell-cafe] Pointfree composition for higher arity
daniel.is.fischer at web.de
Wed Feb 17 10:59:22 EST 2010
Am Mittwoch 17 Februar 2010 16:31:16 schrieb Sean Leather:
> I find myself often writing this pattern:
> someFun x y z = ...
> fun y z = runFun $ someFun someDefault y z
> or, alternatively:
> fun y = runFun . someFun someDefault y
> The second option approaches the ideal pointfreeness (or pointlessness
> if you prefer), but I'd like to go farther:
> (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
> > (...) f g x y = f (g x y)
(...) = (.) . (.)
> > infixr 9 ...
> fun = runFun ... someFun someDefault
> There, that's better. More points for fewer points (which means I should
> really change the name from fun to pun).
> Does anybody else care about this? What are some alternative solutions?
o = (.)
oo = (.) . (.)
ooo = (.) . (.) . (.)
runFun `oo` someFun someDefault
I've also seen
(.:) = (.) . (.)
runFun .: someFun someDefault
I don't particularly like (...), it's too much like an ellipsis (and bad to
count if you continue on that route), I prefer the 'spectacles' or
(∘) = (.)
(∘∘) = (.) . (.)
> I'd love to have something like this available in the Prelude or a
> library. (I have no strong feelings about the particular operator.)
More information about the Haskell-Cafe