1.5 composition of functions

Lets say we have functions f,g such that fg is well defined (i.e. the types match up). Haskell can write this via:

> (f . g) x = f (g x)
> (.) f g x = f (g x) -- Utilize this one if the function names have non-letters in them.

More formally, the composition operator (remember an operator is just a function that maps functions to functions) can be written in Haskell's type system as follows:

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

Note the order! This is a byproduct of f appearing before g whenever we mean to write f(g(x)) even though g is performed first.

And of course, composition is associative, and so Haskell can support ignoring parenthesis (though it is not commutative! so be careful):

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