patch applied (haskell-prime-status): BangPatterns: probably accept ==> undecided

Cale Gibbard cgibbard at gmail.com
Thu Apr 24 14:55:02 EDT 2008


2008/4/24 Wolfgang Jeltsch <g9ks157k at acme.softbase.org>:
> Am Dienstag, 22. April 2008 01:58 schrieb John Meacham:
>  Why should the fixity of $ being changed?  I thought, the reason for $ was
>  that you can write a $ b $ c.

Well, the reasons for this were discussed on another thread recently,
but in brief, you can always rewrite "f $ g $ h $ x" as "f . g . h $
x", whereas there's no way to remove the parentheses from expressions
like "f (g x) (h y) (k z)", which, if ($) were left associative like
function application normally is, could be written "f $ g x $ h y $ k
z".

Moreover, using function composition in place of ($) where possible
should probably be considered better style regardless, as expressions
written that way effectively have more subexpressions, because (.) is
an associative operator. For instance, in "f $ g $ h $ x", the
substring "g $ h" is meaningless, but in "f . g . h $ x", we have that
"g . h" is a well-typed function, as well as "f . g".

Another good reason is that we certainly wouldn't want ($!) to have a
different associativity than ($), and the left-associative form of
($!) is far more useful than the present right-associative one.
Strictly applying a function to any parameter but the last currently
requires awkward parentheses. In combination with left-associating
($), a left-associating ($!) will allow any combination of strict
applications to be easily expressed.

I tend to think of the present associativity of ($) as a kind of
oversight which people started to abuse in place of proper function
composition, whereas the alternate associativity has real benefits
over this one.

 - Cale


More information about the Haskell-prime mailing list