Hey. For a tutorial this week, one of the questions asks to create a function formatLines by using other functions formatLine and formatList, to format a list of lines.
My code looks like this;
type Line = String
formatLine :: Line -> String
formatLine l = l ++ "\n"
formatList :: (a -> String) -> [a] -> String
formatList f [] = []
formatList f xs = f (head xs) ++ formatList f (tail xs)
formatLines :: [Line] -> String
formatLines xs = formatList formatLine xs
The code seems (to me, at least) like it should work, but instead of creating a new line where "\n" is, \n gets appended to the string.
Any help would be greatly appreciated.