<div dir="ltr">Hi Jeremy and the haskell community,<br><br>&nbsp;&nbsp;&nbsp; I think now my question is why isn&#39;t there a higher-order &quot;with&quot; function in the Haskell Prelude?<br><br>Regards, Vasili<br><br><div class="gmail_quote">
On Wed, Aug 6, 2008 at 2:25 AM, Jeremy Shaw <span dir="ltr">&lt;<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
At Wed, 6 Aug 2008 00:43:55 -0500,<br>
Galchin, Vasili wrote:<br>
&gt;<br>
&gt; [1 &nbsp;&lt;multipart/alternative (7bit)&gt;]<br>
&gt; [1.1 &nbsp;&lt;text/plain; ISO-8859-1 (7bit)&gt;]<br>
<div class="Ih2E3d">&gt; Hello,<br>
&gt;<br>
&gt; &nbsp; &nbsp; 1) Is there a common assumed semantics across all of the Haskell &quot;with&quot;<br>
&gt; things? withString? withData?<br>
<br>
</div>A vague semantic is that some resource is acquired, used, and then released.<br>
<div class="Ih2E3d"><br>
&gt; &nbsp; &nbsp; 2) If the answer to 1) is yes, then does this imply some kind of<br>
&gt; polymorphism? Couldn&#39;t &quot;with&quot; be &quot;reduced&quot; to a higher order function then<br>
&gt; ??<br>
<br>
</div>I think Control.Exception.bracket is used to implement many, but not<br>
all, of the with* functions.<br>
<br>
&gt; newThing :: IO a<br>
&gt; newThing = ...<br>
<br>
&gt; destroyThing :: a -&gt; IO b<br>
&gt; destroyThing ...<br>
<br>
&gt; withThing :: (Thing -&gt; IO a) -&gt; IO a<br>
&gt; withThing useThing = bracket newThing destroyThing useThing<br>
<br>
I have not fully answered either of your questions, but hopefully this<br>
is a start.<br>
<font color="#888888"><br>
j.<br>
</font></blockquote></div><br></div>