In Edward Kmett's talk Lenses, Folds, and Traversals, on the slide "The Power is in the Dot", he shows the type of (.) . (.) . (.)
is
(a -> b) -> (c -> d -> e -> a) -> c -> d -> e -> b
I can see it by showing its type in GHCI. But I'd also like to know why. The other thing I'd like to understand is why there's the pattern in the regular change of parameters from (.)
to (.) . (.)
and (.) . (.) . (.)
:
(.) :: (a -> b) -> (c -> a) -> c -> b
(.) . (.) :: (a -> b) -> (c -> d -> a) -> c -> d -> b
(.) . (.) . (.) :: (a -> b) -> (c -> d -> e -> a) -> c -> d -> e -> b
P.S. I tried to resolve (.) . (.)
myself by expanding the function definition of (.) . (.)
. After applying the definition of (.)
I got:
\x y z t -> x ((y z) t)
So I inferred the types:
x :: a -> b
y :: c -> d -> a
z :: c
t :: d
However I got lost on (.) . (.) . (.)
. And I don't know if this is the right way to do manual type inference.
(.)
toresult
. The intuition given in this post is quite nice, and in my opinion makes it quite clear why stacking compositions of(.)
results in the types it does. – Subsoil