[Haskell-cafe] flip dot

Greg Fitzgerald garious at gmail.com
Wed Sep 27 20:33:48 EDT 2006


Since there's talk of removal of the composition operator in
Haskell-prime<http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot>,
how about this:

Instead of:
foo = f . g

you write:
foo = .g.f

A leading dot would mean, "apply all unnamed parameters to the function on
the right".  A trailing dot would mean, "apply the result of the left to the
function on the right".

Prelude> notNull = .null.not
=> [a] -> Bool

notNull [1,2,3]
=> True

[1,2,3].notNull
=> True

[1,2,3].null.not
=> True


I like this because it has the same perks as the composition operator, yet
it looks like OO code and the data flows nicely from left to right.  It
reads especially well when using the bind operator on the same line.

Thoughts?

Thanks,
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20060927/fe2db1fd/attachment.htm


More information about the Haskell-Cafe mailing list