The idea is to understand the operator (.) , It has a type
(.) :: (b -> c) -> (a -> b) -> a -> c
It takes two functions, each with one parameter and their compilation, after applying gx alleged compiler g actually g :: a -> b -> c to satisfy the signature (.) :: (b -> c) -> (a -> b) -> a -> c , which takes two functions with one argument. Otherwise, the code will not compile.
And finally, if you need the signature f :: (t -> t) -> t -> t , you need something like this:
λ> let applyTwice g = gg λ> :t applyTwice applyTwice :: (a -> a) -> a -> a λ> applyTwice (*2) 3 12
source share