If
*Main> :t concatMap
concatMap :: (a -> [b]) -> [a] -> [b]
and
*Main> :t replicate
replicate :: Int -> a -> [a]
then how does that work
*Main> :t concatMap . replicate
concatMap . replicate :: Int -> [b] -> [b]
given:
*Main> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
?
I mean, my understanding of function composition is that replicate should return whatever concatMap expects as arguments in order for (.) to work. But it does not LOOK to be the case. So what is the catch?
It might help you to see what’s going on if you add parentheses to the signatures and then line them up:
Now it should be fairly obvious that the output of
replicatefits the input ofconcatMapif we unifybanda, in which case the output type of the composition is[b] -> [b].