Scherrer, Chad wrote:
> 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.

It is, and only because (.) is defined all wrong!

The unix pipe is actually function composition.  Its argument (standard
input) isn't explicitly mentioned, so the analogous Haskell code should
do the same.  However, function composition reads backwards, which makes
code quite unreadable, especially when (.), (>>=) and `liftM` (which
also has an all wrong fixity) are mixed.

Im summary, I'd define

infixl 0 #
infixl 1 >>#
infixl 2 \|
(#)   = flip ($)
(>>#) = flip liftM
(\|)  = flip (.) -- though I'm using (&)

The unix pipe becomes (filter ("foo" `isPrefixOf`) \| sort \| nub) or
something, which is rather neat, and (#) is used to call "member
functions", as in

some_map # add key value
         # add something or_other
         # delete old_trash

which actually gives the result one expects when reading it top to bottom.
In summary, (.) is tremendously useful, but it would be even better if
it had the correct argument order.  Unfortunately, this cannot be
corrected any more.


Udo.
-- 
"God is real, unless declared as an Integer." - Unknown Source

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to