[Haskell-cafe] Point-free style
fruehr at willamette.edu
Mon Feb 14 18:42:12 EST 2005
On Feb 14, 2005, at 2:07 AM, Daniel Fischer wrote:
> A question for the point-free society:
> Is there any advantage of defining
> (.<) = (.) . (.)
> rather than
> f .< g = \x y -> f (g x y) -- or f $ g x y ?
> Analogous question for (.) . (.) . (.) etc.
Well, from the fact that you even pose the question, and
remarks from Simon Marlow, I'm guessing that "out of sheer impish
"to tickle the aesthetic sense the way a bump to the elbow tickles the
are not the sort of answers you're looking for :) .
(Note that others have since risen to the occasion in this vein. And
remember that all
these "dotted dots" were Jerzy's fault, not mine, and that beer was at
hand ... .)
More seriously, however, the generalization to n raises some
For surely we are tempted to something like this, in a half-imagined
(read the LHS as "dot sub n"):
(. _ n) = foldl1 (.) (replicate n (.))
And, just as surely, we shouldn't be satisfied with the answer
don't do dat" * . Rather, we should seek out ways to extend the type
the language so that we could make this abstraction, and others like
are compelling at some basic level.
The point being, this generalization might not occur to us (and drive
new heights, etc.) if we didn't express it in the more "precious" style.
PS: Which is not to say that the Haskell type system can't be wrenched
cajoled, gently plied with sweet whispers ...) into doing things
this, using type-level natural numbers, or perhaps
constructors. I'm sure that "extreme typists" like Oleg and Ken do this
thing to warm up in the morning, the way other typists (the mundane
their fingers together and stretch them out before settling in to their
But perhaps someone else should post some code along these lines, lest
Ken despair too much of having wasted their efforts on us. I promise to
a few ideas myself when I get the chance.
* (take no offense: just a reference to the old "In Living Color"
More information about the Haskell-Cafe