(.) :: (b -> c) -> (a -> b) -> a -> c
f . g = \x -> f(g x)
I don’t quite understand how to read the function type.
(b -> c)is a function takes an argument b, returns c, i assume this is function f(a -> b)is a function takes an argument a, return b, i assume this is function g
not sure how are c in (b -> c) and a in (a -> b) are relate to a -> c
any help will be greatly appreciated, thanks!
Perhaps it’s better to parenthesise a bit more,
and read it:
(.)takes two arguments,f) of typeb -> cg) of typea -> band returns a function (
f . g) of typea -> c.The argument type
aof the resulting function is the type of the argument of(.)‘s second argument (g, which is first applied to the argument off . g), and the result type of the composition is the result type of(.)‘s first argument (f, which is then applied to the result of the application ofgto the argument).