Phased improvement ("ukaskelenie") solutions:
0. Add signature
printList :: [String] -> IO () printList list = case list of [] -> putStrLn "" (x:xs) -> do putStrLn $ show x printList xs
1. Disappears case:
printList :: [String] -> IO () printList [] = putStrLn "" printList (x:xs) = do putStrLn $ show x printList xs
2. Disappears do:
printList :: [String] -> IO () printList [] = putStrLn "" printList (x:xs) = (putStrLn $ show x) >> printList xs
3. Explicit recursion disappears (true, the empty line at the end disappears too):
printList :: [String] -> IO () printList = mapM_ $ putStrLn . show
4. Generalization from lines to any objects to which show can be applied:
printList :: Show a => [a] -> IO () printList = mapM_ $ putStrLn . show
5. The expression putStrLn . show putStrLn . show equivalent to the print function.
printList :: Show a => [a] -> IO () printList = mapM_ print
If anyone is interested, I can break the point "3." into smaller steps.