[Haskell-cafe] Re: haskell programming guidelines

ajb at spamcop.net ajb at spamcop.net
Thu Feb 23 00:27:23 EST 2006


G'day all.

Quoting Christian Maeder <maeder at tzi.de>:

> I see this differently. Expressions may be succinct! I find "$" and "."
> similar enough for non-obfuscation.

But they're _not_ similar!

Compare this notation:

    f . g . h $ x

with the one you suggested:

    f $ g $ h $ x

Advantages of the first one:

    - Encourages the idea that there is function composition going on.
      Function composition is one of the features of functional
      programming, so this should be highly encouraged.

    - Protects your code against the day when the committee realises that
      ($) has the wrong associativity.  (It's the opposite of what you'd
      expect, since normal function application is left-associative.)

Disadvantages:

    - None whatsoever.  It's just as succinct and uses just as many
      parentheses.

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list