[Haskell-cafe] haskell programming guidelines

ajb at spamcop.net ajb at spamcop.net
Mon Feb 20 17:53:54 EST 2006


G'day.

Quoting Christian Maeder <maeder at tzi.de>:

>
http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/src-distribution/versions/HetCATS/docs/Programming-Guidelines.txt

As mentioned in an earlier discussion, I strongly disapprove of the use
of multiple ($) applications in the same expression.  Or, for that matter,
most uses of ($).  I also disapprove of avoiding parentheses for the hell
of it.

The guideline that I use is: If what you are expressing is a chain of
function applications, the correct operator to express this is function
composition.  Low-priority application may then be used to apply this
composed function to an argument.

So, for example, f (g (h x)) can be expressed well as:

    f . g $ h x          -- only use if you need to distinguish h
    f . g . h $ x        -- better

And poorly as:

    f $ g $ h x
    f $ g $ h $ x
    (f . g . h) $ x      -- except as an intermediate step in refactoring

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list