This probably helps explicitly bracket the signatures:
selfAppend :: Int -> ([a] -> [a]) replicate :: Int -> ([a]->[[a]]) concat :: [[a]] -> [a]
If you try to make concat . replicate concat . replicate , you will get concat partially appied result of replicate , i.e. [a] -> [[a]] . This is not combined with [[a]] .
You need to pass both arguments to replicate first before passing the result. IMO the best way to do this is βhalf-toneβ:
selfAppend n = concat . replicate n
Less readable alternatives would be
selfAppend' = curry $ concat . uncurry replicate selfAppend'' = (concat.) . replicate
Or with the infamous operator
(.:) :: (c->d) -> (a->b->c) -> a->b->d (.:) = (.).(.) -- `β‘ fmap fmap fmap`, also a popular implementation...
you can just write
selfAppend''' = concat .: replicate
source share