<div dir="ltr"><br><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 5:17 PM, Nicolas Pouillard <span dir="ltr">&lt;<a href="mailto:nicolas.pouillard@gmail.com">nicolas.pouillard@gmail.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;">
<div class="im">On Tue, Oct 20, 2009 at 3:12 PM, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard<br>
&gt; &lt;<a href="mailto:nicolas.pouillard@gmail.com">nicolas.pouillard@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; While working on the next release of data-object, I wanted to represent<br>
<br>
</div>[...]<br>
<div class="im"><br>
&gt;&gt; About the name Attempt, I think that &#39;Outcome&#39; would be a better name.<br>
&gt;<br>
&gt; The problem with a name like &quot;Outcome&quot; is that it doesn&#39;t really imply the<br>
&gt; possibility of failure, simply that we are wrapping of the result for some<br>
&gt; reason.<br>
<br>
</div>I don&#39;t see why, the outcome of an action could be either a success or<br>
a failure.<br>
Even if the only *desired* outcome is success.<br></blockquote><div><br>I think I&#39;m going to stick with Attempt. The only other point that came to me is it&#39;s nicer to have a function called &quot;attempt&quot; than &quot;outcome&quot; IMO. <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
&gt;&gt; &gt; 2) Are there any other FromAttempt instances I should provide out of the<br>
&gt;&gt; &gt; box?<br>
&gt;&gt;<br>
&gt;&gt; None that I see.<br>
&gt;&gt;<br>
&gt;&gt; &gt; 3) I was considering adding specialized versions of the fromAttempt<br>
&gt;&gt; &gt; function, ie ioFromAttempt, maybeFromAttempt. Thoughts?<br>
&gt;&gt;<br>
&gt;&gt; It is a bit long to spell.<br>
&gt;<br>
&gt; True, but it can be more convenient than giving explicit type signatures.<br>
&gt; The main reason this might come up would be regarding the (Either String)<br>
&gt; and (Either SomeException) instances.<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or<br>
&gt;&gt; &gt; just call the functions join, lookup and force people to import the<br>
&gt;&gt; &gt; module<br>
&gt;&gt; &gt; qualified?<br>
&gt;&gt;<br>
&gt;&gt; A nice alternative would be to make a Data.Attempt.Extra (or a better<br>
&gt;&gt; name) which<br>
&gt;&gt; would be imported qualified.<br>
&gt;<br>
&gt; I like. The only other name I can think of right now is Data.Attempt.Helper,<br>
&gt; but that&#39;s just painting the bike shed.<br>
<br>
</div>I also prefer Helper.<br></blockquote><div><br>Done. Not full-featured yet, but does provide a nice core. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im"><br>
&gt;&gt; &gt; 5) Any other suggestions for attempt functions? I&#39;ve considered<br>
&gt;&gt; &gt; head/tail/etc.<br>
&gt;&gt;<br>
&gt;&gt; Why not, maybe the &#39;safe&#39; package should be of some inspiration.<br>
&gt;<br>
&gt; Once they&#39;re all in their own module, I don&#39;t see a problem adding as many<br>
&gt; as possible.<br>
<br>
</div>[...]<br>
<div class="im"><br>
&gt;&gt; attempt :: (forall e. Exception e -&gt; b) -&gt; (a -&gt; b) -&gt; Attempt a -&gt; b<br>
&gt;&gt;<br>
&gt; I was trying to more model it after fromMaybe, but instead just ended up<br>
&gt; with something ugly. I&#39;m going to rewrite attempt using this type signature<br>
&gt; and then add fromAttempt as well.<br>
<br>
</div>Fine, fromAttempt should follow fromMaybe<br>
<br>
fromAttempt :: (forall e. Exception e -&gt; a) -&gt; Attempt a -&gt; a<br>
fromAttempt f a = attempt f id a<br></blockquote><div><br>And of course I now realize this name will conflict with the FromAttempt typeclass ;). I think we&#39;ll be safe leaving this function out, considering how trivial it is to implement in terms of attempt.<br>
<br>Also, I&#39;ve added a monad transformer to the github repo. I&#39;ve tried it out in some local code I have, and it *really* cleans up the error handling.<br><br>Michael <br></div></div></div>