
I have the following code which works fine: type File = (String, String) --name and content readDir :: String -> IO [File] readDir dir = findRegularFiles dir >>= readFiles where findRegularFiles = find always (fileType ==? RegularFile) readFiles paths = mapM readFile paths >>= return.zip paths ...and I would like to write the function readDir like this: readDir :: String -> IO [File] readDir = findRegularFiles >>= readFiles where ... ...but I get the error: grep.hs:46:32: Couldn't match expected type `IO [FilePath]' with actual type `[FilePath]' Expected type: IO [FilePath] -> String -> IO [File] Actual type: [FilePath] -> IO [File] In the second argument of `(>>=)', namely `readFiles' In the expression: findRegularFiles >>= readFiles Can somebody please explain it? It's not a big deal. I can keep the old version which works fine. My only problem is that I thought I understood the monads better but apparently I don't :)