I'm having a strange problem when copying a list of files in Haskell. If I run the following code:
copy :: [FilePath] -> FilePath -> IO ()
-- Precondition: dir must be a directory.
copy fs dir = do
isDir <- doesDirectoryExist dir
if (isDir)
then do
mapM_ putStrLn fs -- Poor man's debug.
mapM_ (`copyFile` dir) fs
else ioError (userError $ dir ++ " is not a directory.")
The output of mapM_ putStrLn fs
gives a single file, which extists, however the second mapM_
fails with the following message:
./.copyFile4363.tmp: copyFile: inappropriate type (Is a directory)
I'm really puzzled, since in both uses of mapM_
the list fs
is passed as parameter.
Am I overlooking something?