Hi Erik,<div>The short answer to your question is to not write splitDirFile to operate on FilePaths, but on some wrapper around FilePaths that also contain information about whether each path is to a directory or a file. Then you can call splitDirFile purely. For the long, but very good, answer, see RWH, where they discuss this very specifically:&nbsp;<a href="http://book.realworldhaskell.org/read/io-case-study-a-library-for-searching-the-filesystem.html">http://book.realworldhaskell.org/read/io-case-study-a-library-for-searching-the-filesystem.html</a><br>
<div><br><div class="gmail_quote">On Tue, Jan 27, 2009 at 11:07 PM, Erik de Castro Lopo <span dir="ltr">&lt;<a href="mailto:mle%2Bcl@mega-nerd.com">mle+cl@mega-nerd.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi all,<br>
<br>
I have a list of entries for a directory (FilePaths) and I&#39;d like to<br>
partition them into files and directories using Data.List.partition:<br>
<br>
 &nbsp; &nbsp;partition :: [a] -&gt; ([a], [a])<br>
<br>
Now, one solution is to use unsafePerformIO:<br>
<br>
 &nbsp; &nbsp;splitDirFile :: [FilePath] -&gt; ([FilePath], [FilePath])<br>
 &nbsp; &nbsp;splitDirFile paths = do<br>
 &nbsp; &nbsp; &nbsp; &nbsp;partition (\p -&gt; unsafePerformIO (doesDirectoryExist p)) paths<br>
<br>
Two questions:<br>
<br>
 &nbsp;a) Is it possible to do this without invoking unsafePerformIO? Ie with<br>
 &nbsp; &nbsp; a function signature of say:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; partition :: [FilePath] -&gt; IO ([FilePath], [FilePath])<br>
<br>
 &nbsp;b) Exactly how unsafe is the unsafePerformIO version?<br>
<br>
Erik<br>
--<br>
-----------------------------------------------------------------<br>
Erik de Castro Lopo<br>
-----------------------------------------------------------------<br>
The main confusion about C++ is that its practitioners think<br>
it is simultaneously a &nbsp;high and low level language when in<br>
reality it is good at neither.<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div></div>