[Haskell-beginners] f . g or f g or f $ g?
es at ertes.de
Fri Feb 1 23:02:39 CET 2013
Martin Drautzburg <Martin.Drautzburg at web.de> wrote:
> I frequently get confused over f . g vs f g. I do understand the
Out of the three choices "f . g", "f g" and "f $ g", only the dot
operator has a special meaning. The others are the same thing.
Remember the function composition operator from math? It's the circle
operator. That's how you should read the dot. In fact, if you use
Emacs, you can make it display the dot that way. The haskell-mode has
this built in.
(f . g) x = f (g x)
There is also something interesting to note about application:
f $ x = ($) f x
($) f x = f x
From that follows:
($) f = f
And from that follows:
($) = id
id :: a -> a
($) :: (a -> b) -> (a -> b)
($) is really just id with a more special type.
I hope this helps. =)
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners