Higher Order Functions

Higher Order Functions

Functions like map, filter and foldr are also called higher order functions, becuase they take a function as their argument. A higher order function takes a function as its argument or/and returns a function as it’s result.

Here are some more examples of such functions.

apply :: forall a b. (a -> b) -> a -> b
apply f x = f x

compose :: forall a b. (b -> c) -> (a -> b) -> a -> c
compose g f x = g (f x)