[Haskell-beginners] difference between . and $

Rafael Gustavo da Cunha Pereira Pinto RafaelGCPP.Linux at gmail.com
Sun Oct 30 19:41:41 CET 2011


No, not really

the '.' operator is function composition, so f.g is a new function with f
applied over g.

h=f.g ==> h x = f ( g x )

the '$' is the apply operator, and it applies the right side to the left
side:

h = f $ x ==> h= f ( x )


You can check this looking at their types

(.) :: (b -> c) -> (a -> b) -> a -> c
($) :: (a -> b) -> a -> b

the first one takes two functions and return a new function. The second
takes a function and a value and returns a value.

Regards

Rafael

On Sun, Oct 30, 2011 at 15:39, <haxl at nym.hush.com> wrote:

> Doesn't . and $ do the same thing?  I always get confused about
> that, like when would I use one over the other.
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Rafael Gustavo da Cunha Pereira Pinto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111030/bd4ad7f3/attachment.htm>


More information about the Beginners mailing list