[Haskell-cafe] symbol $

Stefan Holdermans stefan at cs.uu.nl
Mon May 7 10:46:51 EDT 2007


Maverick,

> Do you mind tell what is mean by the symbol $ in this piece of  
> code? Thanks
> a lot.

It denotes function application:

   infixr 1 $

   ($)   :: (a -> b) -> a -> b
   f $ x =  f x

Note how its precedence and associativity is the opposite of that of  
'regular' function application. The ($) is typically used to limit  
the number of parentheses needed in a piece of code:

   f (g (h x)) vs. f $ g $ h $ x

There are other options though:

   (f . g . h) x
   f . g . h $ x

HTH,

   Stefan


More information about the Haskell-Cafe mailing list