<div dir="ltr"><br><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 5:17 PM, Nicolas Pouillard <span dir="ltr"><<a href="mailto:nicolas.pouillard@gmail.com">nicolas.pouillard@gmail.com</a>></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 <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>> wrote:<br>
><br>
><br>
> On Tue, Oct 20, 2009 at 11:04 AM, Nicolas Pouillard<br>
> <<a href="mailto:nicolas.pouillard@gmail.com">nicolas.pouillard@gmail.com</a>> wrote:<br>
>><br>
>> On Sun, Oct 18, 2009 at 9:45 PM, Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>><br>
>> wrote:<br>
>> > While working on the next release of data-object, I wanted to represent<br>
<br>
</div>[...]<br>
<div class="im"><br>
>> About the name Attempt, I think that 'Outcome' would be a better name.<br>
><br>
> The problem with a name like "Outcome" is that it doesn't really imply the<br>
> possibility of failure, simply that we are wrapping of the result for some<br>
> reason.<br>
<br>
</div>I don'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'm going to stick with Attempt. The only other point that came to me is it's nicer to have a function called "attempt" than "outcome" 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>
>> > 2) Are there any other FromAttempt instances I should provide out of the<br>
>> > box?<br>
>><br>
>> None that I see.<br>
>><br>
>> > 3) I was considering adding specialized versions of the fromAttempt<br>
>> > function, ie ioFromAttempt, maybeFromAttempt. Thoughts?<br>
>><br>
>> It is a bit long to spell.<br>
><br>
> True, but it can be more convenient than giving explicit type signatures.<br>
> The main reason this might come up would be regarding the (Either String)<br>
> and (Either SomeException) instances.<br>
><br>
>><br>
>> > 4) Should I follow the naming scheme attemptJoin, attemptLookup, etc, or<br>
>> > just call the functions join, lookup and force people to import the<br>
>> > module<br>
>> > qualified?<br>
>><br>
>> A nice alternative would be to make a Data.Attempt.Extra (or a better<br>
>> name) which<br>
>> would be imported qualified.<br>
><br>
> I like. The only other name I can think of right now is Data.Attempt.Helper,<br>
> but that'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>
>> > 5) Any other suggestions for attempt functions? I've considered<br>
>> > head/tail/etc.<br>
>><br>
>> Why not, maybe the 'safe' package should be of some inspiration.<br>
><br>
> Once they're all in their own module, I don't see a problem adding as many<br>
> as possible.<br>
<br>
</div>[...]<br>
<div class="im"><br>
>> attempt :: (forall e. Exception e -> b) -> (a -> b) -> Attempt a -> b<br>
>><br>
> I was trying to more model it after fromMaybe, but instead just ended up<br>
> with something ugly. I'm going to rewrite attempt using this type signature<br>
> and then add fromAttempt as well.<br>
<br>
</div>Fine, fromAttempt should follow fromMaybe<br>
<br>
fromAttempt :: (forall e. Exception e -> a) -> Attempt a -> 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'll be safe leaving this function out, considering how trivial it is to implement in terms of attempt.<br>
<br>Also, I've added a monad transformer to the github repo. I'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>