1.5 composition of functions
Lets say we have functions
> (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
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