[Haskell-beginners] the ($) function (was desugaring an example from RWH)

John Hartnup john.hartnup at gmail.com
Mon Feb 23 14:21:06 EST 2009


I had exactly the same confusion - not explaining ($) in RWH was major
dropped ball IMO.

>
> bogusTransfer qty fromBal toBal = do
>     fromQty <- atomically $ readTVar fromBal
>     [snip]
>

... is equivalent to:
bogusTransfer qty fromBal toBal = do
     fromQty <- atomically ( readTVar fromBal
     [snip]
     )

... so using ($) prevents accumulating a great big set of parentheses
to close at the end of a long block.


-- 
"There is no way to peace; peace is the way"


More information about the Beginners mailing list