What does (f .) . g mean in Haskell?
I have seen a lot of functions being defined according to the pattern (f .) . g . For example: countWhere = (length .) . filter duplicate = (concat .) . replicate concatMap = (concat .) . map What does this mean? The dot operator (i.e. (.) ) is the function composition operator. It is defined as follows: infixr 9 . (.) :: (b -> c) -> (a -> b) -> a -> c f . g = \x -> f (g x) As you can see it takes a function of type b -> c and another function of type a -> b and returns a function of type a -> c (i.e. which applies the first function to the result of the second function). The function