First, your function is concatMap from Prelude.
More idiomatic ways to write it:
myFold :: (a -> [b]) -> [a] -> [b]
myFold = concat . map
-- or
myFold f = foldlfoldr (\acc\x xacc -> (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. ConsiderData.Sequenceor evenvectors. - Avoid lazyness in your types
- Provide all small functions with
INLINEpragma. - And more...