<p dir="ltr">I think a lot of people have raised a lot of important concerns. Henning's point, I think, is particularly enlightening: "I would not like the name safeWithFile, because withFile is already safe. It's hGetContents that is unsafe." It also composes very poorly—using the contents of more than one file to compute a result will lead to a double application of deepseq. I'm not sure how to address those concerns. One possible path is to have a safeHGetContents, along with RULES in Control.DeepSeq to attempt to erase the double deepseq.</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">I would support adding this function under the name `withFile`, in a new module exported by the deepseq package, as Henning seems to be suggesting.  I don't think it's particularly important, but this pattern arises often enough that I think it's worthwhile.</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">John L.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 13, 2014 at 12:14 AM, Henning Thielemann <span dir="ltr"><<a href="mailto:lemming@henning-thielemann.de" target="_blank">lemming@henning-thielemann.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
On Sun, 12 Oct 2014, Oliver Charles wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Where are you suggesting this library goes? Your `safeWithFile` needs `NFData`, but that's in `deepseq` which<br>
isn't a dependency of `base`.<br>
</blockquote>
<br></span>
It would certainly be located in 'deepseq' or a dependent library. Maybe Control.DeepSeq.IO.withFile would be good. Then it would be clear, that it is just a deepseq variant of withFile.<br>
<br>
I would not like the name safeWithFile, because withFile is already safe. It's hGetContents that is unsafe.<div><div><br>
______________________________<u></u>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
<br></div>