I have a function that is meant to combine strings in a list, adding a separator in between each and outputting a single string using foldl. Here is what I have and some expected behavior of the function -- It isn't working and I'm unsure why.
-- | `sepConcat sep [s1,...,sn]` returns `s1 ++ sep ++ s2 ++ ... ++ sep ++ sn`
--
-- >>> sepConcat "---" []
-- ""
--
-- >>> sepConcat ", " ["foo", "bar", "baz"]
-- "foo, bar, baz"
--
-- >>> sepConcat "#" ["a","b","c","d","e"]
-- "a#b#c#d#e"
sepConcat :: String -> [String] -> String
sepConcat sep [] = ""
sepConcat sep (x:xs) = foldLeft f base l
where
f a x = a ++ sep ++ x
base = ""
l = xs