[Haskell-cafe] Function application like a Unix pipe

Scherrer, Chad Chad.Scherrer at pnl.gov
Tue Nov 22 17:09:40 EST 2005

"Albert Lai" <trebla at vex.net> writes:

> I offer a simpler, more direct, and pre-existing correspondence
between a functional 
> programming construct and unix pipes:

Maybe my point wasn't clear. Of course this idea of comparing lazy
evaluation to Unix pipes is very old (long before July 2004, I'm sure).
The point I'm making is that there is an old idea that may be underused.
We use ($) all over the place, but if there are a lot of them (and
especially if they are spread over several lines) it becomes awkward to
read the whole thing backward to trace through the function from
beginning to end. In these cases, it's much simpler to use 

(\|) = flip ($) -- (#) seems to me too pretty for other purposes to use
it here.
infixl 0 \|     -- Again, why can't this be negative or Fractional??

What I'm asking is really a question of pedagogy and style. This style
seems reasonable to me. OTOH, there are some reasons not to do things in
this way. Maybe any function big enough to benefit from writing it this
way should be broken up anyway. Or maybe getting used to this style
where the laziness is right in your face could make it more difficult
for people to learn to reason through less obvious laziness. I'm really
trying to figure out whether this approach is worth pursuing, rather
than imply that this is a completely original idea.

Chad Scherrer
Computational Mathematics Group
Pacific Northwest National Laboratory

"Time flies like an arrow; fruit flies like a banana." -- Groucho Marx

More information about the Haskell-Cafe mailing list