Haskell Listing Directories in Working Directory
Instead of fIO f xs &gt;&gt;= return . ((if matches then [x] else []) ++), you can use &lt;$&gt;:

([x | matches] ++) &lt;$&gt; fIO f xs


Applicative style would allow you to compress all this yet further:

fIO f (x:xs) = (\matches -&gt; ([x | matches] ++)) &lt;$&gt; f xs &lt;*&gt; fIO f xs


But in the end:

fIO = filterM