[Haskell-cafe] Exercise in point free-style
robdockins at fastmail.fm
Fri Sep 1 12:17:40 EDT 2006
On Friday 01 September 2006 11:44, Neil Mitchell wrote:
> > func2 f g l = filter f (map g l)
> > is
> > func2p f g = (filter f) . (map g)
> func2 = (. map) . (.) . filter
> Again, how anyone can come up with a solution like this, is entirely
> beyond me...
To answer part of the OP's question, it's always possible to rewrite a lambda
term using point-free style (using a surprisingly small set of basic
combinators). The price you pay is that the new term is often quite a bit
larger than the old term. Rewriting complicated lambda terms as point-free
terms is often of, em, dubious value. OTOH, it can be interesting for
understanding arrows, which are a lot like monads in points-free style (from
what little experience I have with them).
BTW, the process of rewriting can be entirely automated. I assume the
lambdabot is using one of the well-known algorithms, probably tweaked a bit.
Goolge "combinatory logic" or "Turner's combinators" if you're curious.
Talk softly and drive a Sherman tank.
Laugh hard, it's a long way to the bank.
More information about the Haskell-Cafe