[Haskell-cafe] Pointfree composition for higher arity
matt at immute.net
Sat Feb 20 16:22:09 EST 2010
On Fri, Feb 19, 2010 at 10:42 PM, wren ng thornton <wren at freegeek.org> wrote:
> Sean Leather wrote:
>> 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 ...
> I go with infixl 8 personally. It seems to play better with some of the
> other composition combinators.
> In a somewhat different vein than Oleg's proposed general composition, I've
> particularly enjoyed Matt Hellige's pointless fun combinators. I have a
> version which also adds a strict application combinator in my desiderata
> package so we can say things like:
> foo $:: bar ~> baz !~> bif
> which translates to:
> \a b -> bif (foo (bar a) (baz $! b))
> These combinators are especially good when you don't just have a linear
> chain of functions.
Thanks! I'm glad to know that people have found this approach useful.
In cases where it works, I find it somewhat cleaner than families of
combinators with (what I find to be) rather obscure names, or much
worse, impenetrable sections of (.). We can write the original example
in this style:
fun = someFun someDefault $:: id ~> id ~> runFun
but unfortunately, while it's both pointfree and fairly clear, it
isn't really an improvement over the pointful version, IMHO.
More information about the Haskell-Cafe