Hi all,
There's a common little situation I keep bumping up against. I don't understand
where I'm going wrong, so I've made a little example. It's to do with binding a
result to a variable name using "<-". This code works fine:
----------------------------------------------
module Main where
import System.Directory (getDirectoryContents)
main = do dc <- getDirectoryContents "./foo/"
mapM_ putStrLn dc
----------------------------------------------
But if I try to avoid the use of the bind to "dc", I fail:
----------------------------------------------
mapM_ putStrLn (getDirectoryContents "./foo/")
----------------------------------------------
I've tried using map instead of mapM_, and inserted "return"s here and there,
but no luck. Can anyone tell me where and why I'm going wrong? The error
message is below.
Cheers,
Paul
Couldn't match expected type `[String]'
against inferred type `IO [FilePath]'
In the second argument of `mapM_', namely
`(getDirectoryContents "./foo/")'
In the expression: mapM_ putStrLn (getDirectoryContents "./foo/")
In the definition of `main':
main = mapM_ putStrLn (getDirectoryContents "./foo/")
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe