[Haskell-cafe] About ($)
cgibbard at gmail.com
Thu Jun 2 15:07:11 EDT 2005
(oops, wanted to reply to the list, sent this directly the first time)
It's not all that much, but there are some uses outside of getting rid
of parentheses. What do you want for something defined as "f $ x = f
It's just the identity function restricted to functions. You might
occasionally see something along the lines of "zipWith ($) fs xs" to
apply each function in the list fs to the corresponding element of the
list xs. While "zipWith id fs xs" also works, it's not quite as clear
to the reader what is going on. ($) means "apply this function to this
value" specifically, while id doesn't quite have that overtone.
My take is that it's somewhat like otherwise = True. It's mostly there
to clear up syntax and give some clues as to meaning.
More information about the Haskell-Cafe