Implement a fold-like Function in Haskell
First, your function is concatMap from Prelude.

More idiomatic ways to write it:

myFold :: (a -&gt; [b]) -&gt; [a] -&gt; [b]
myFold = concat . map
-- or
myFold f = foldr (\x acc -&gt; (f x) ++ acc) []


If efficiency is a concern, it's a completely different question. Recommended steps in priority order:


Always compile at least with -O2
Lists are slow. ++ operation especially. Consider Data.Sequence or even vectors.
Avoid lazyness in your types
Provide all small functions with INLINE pragma.
And more...