I have these two code snippets, which I'd guess do the same thing, but they don't. Why is that?
This one works fine:
fdup :: String -> IO ()
fdup filename = do
h <- openFile filename ReadMode
c <- hGetContents h
putStr $ unlines $ parse $ lines c
hClose h
This one returns an error Couldn't match expected type ‘IO [String]’ with actual type ‘[String]’
:
fdup' :: String -> IO ()
fdup' filename = do
h <- openFile filename ReadMode
c <- hGetContents h
ls <- lines c
putStr $ unlines $ parse $ ls
hClose h
parse :: [String] -> [String]
What is the difference between them?