[Haskell-beginners] f . g or f g or f $ g?

Emanuel Koczwara poczta at emanuelkoczwara.pl
Tue Feb 12 22:23:50 CET 2013


Hi,

Dnia 2013-02-12, wto o godzinie 22:09 +0100, Martin Drautzburg pisze:
> On Friday, 1. February 2013 23:02:39 Ertugrul Söylemez wrote:
> 
> >     (f . g) x = f (g x)
> 
> 
> so (f . g) x = f $ g x
> 
> right?
> 
> That looks like the two are pretty interchangeable. When would I prefer one 
> over the other?
> 
> 

($) has lower precedence (it was introduced for that reason I belive).

Prelude> :info ($)
($) :: (a -> b) -> a -> b 	-- Defined in GHC.Base
infixr 0 $

Please take a look at: 
http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36-



More information about the Beginners mailing list