<font face="verdana,sans-serif">I'm not sure that exposing a liftIO for Monad.Par is the best idea. Since all these parallel computations use runPar :: Par a -> a, it advertises that the result is deterministic. I'm not really comfortable with a hidden unsafePerformIO hiding in the background.</font><div>
<font face="verdana,sans-serif"><br></font></div><div><font face="verdana,sans-serif">That said, I don't see a reason for not including a separate version of runParIO :: ParIO a -> IO a for non-deterministic computations. It seems really useful!</font></div>
<div><font face="verdana,sans-serif"><br></font></div><div><font face="verdana,sans-serif">Regards,</font></div><div><font face="verdana,sans-serif"> - Clark<br></font><br><div class="gmail_quote">On Wed, Oct 3, 2012 at 10:24 AM, Ryan Newton <span dir="ltr"><<a href="mailto:rrnewton@gmail.com" target="_blank">rrnewton@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Several of the monad-par schedulers COULD provide a MonadIO instance and thus "liftIO", which would make them easy to use for this kind of parallel IO business:</div>
<div><br></div><div> <a href="http://hackage.haskell.org/packages/archive/monad-par/0.3/doc/html/Control-Monad-Par-Scheds-Direct.html" target="_blank">http://hackage.haskell.org/packages/archive/monad-par/0.3/doc/html/Control-Monad-Par-Scheds-Direct.html</a></div>
<div><br></div><div>And that would be a little more scalable because you wouldn't get a separate IO thread for each parallel computation. But, to be safe-haskell compliant, we don't currently expose IO capabilities. I can add another module that exposes this capability if you are interested...</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div> -Ryan</div><br></font></span><div class="gmail_quote"><div><div class="h5">On Fri, Sep 28, 2012 at 4:48 PM, Alexander Solla <span dir="ltr"><<a href="mailto:alex.solla@gmail.com" target="_blank">alex.solla@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><br><br><div class="gmail_quote"><div>On Fri, Sep 28, 2012 at 11:01 AM, Greg Fitzgerald <span dir="ltr"><<a href="mailto:garious@gmail.com" target="_blank">garious@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I also tried Control.Parallel.Strategies [2]. While that route works,<br>
I had to use unsafePerformIO. Considering that IO is for sequencing<br>
effects and my IO operation doesn't cause any side-effects (besides<br>
hogging a file handle), is this a proper use of unsafePerformIO?<br></blockquote><div><br></div></div><div>That's actually a perfectly fine use for unsafePerformIO, since the IO action you are performing is pure and therefore safe (modulo your file handle stuff).</div>
<div><br></div><div>unsafePerformIO is a problem when the IO action being run has side effects and their order of evaluation matters (since unsafePerformIO will cause them to be run in an "unpredictable" order)</div>
<div><br></div><div>One common use for unsafePerformIO is to run a query against an external library. It has to be done in the IO monad, but it is a "pure" computation insofar as it has no side-effects that matter. Doing this lets us promote values defined in external libraries to bona fide pure Haskell values.</div>
</div>
<br></div></div><div class="im">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></div></blockquote></div><br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>