I have the following code which works fine:<br><br><div style="margin-left:40px">type File = (String, String) --name and content<br><br>readDir :: String -&gt; IO [File]<br>readDir dir = findRegularFiles dir &gt;&gt;= readFiles<br>
  where<br>    findRegularFiles = find always (fileType ==? RegularFile)<br>    readFiles paths = mapM readFile paths &gt;&gt;= return.zip paths<br></div><br>...and I would like to write the function readDir like this:<br>
<div style="margin-left:40px">readDir :: String -&gt; IO [File]<br>
readDir = findRegularFiles &gt;&gt;= readFiles<br>  where ...<br></div><br>...but I get the error:<br><div style="margin-left:40px">grep.hs:46:32:<br>    Couldn&#39;t match expected type `IO [FilePath]&#39;<br>                with actual type `[FilePath]&#39;<br>
    Expected type: IO [FilePath] -&gt; String -&gt; IO [File]<br>      Actual type: [FilePath] -&gt; IO [File]<br>    In the second argument of `(&gt;&gt;=)&#39;, namely `readFiles&#39;<br>    In the expression: findRegularFiles &gt;&gt;= readFiles<br>
</div><br>Can somebody please explain it?<br><br>It&#39;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&#39;t :)<br>