Again, at this juncture it sounds like effort would be better spent first writing out an alternative userland lib to understand these design ideas / articulate their impact better <span></span><br><br>On Friday, July 15, 2016, David Thomas <<a href="mailto:davidleothomas@gmail.com">davidleothomas@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I kinda like "ExceptionDisposition" for the type, no particular ideas<br>
on the constructors. Offered only in the spirit of tossing out ideas<br>
- feel free to ignore me if it's not helpful :)<br>
<br>
On Thu, Jul 14, 2016 at 3:20 PM, Carter Schonwald<br>
<<a href="javascript:;" onclick="_e(event, 'cvml', 'carter.schonwald@gmail.com')">carter.schonwald@gmail.com</a>> wrote:<br>
> At this point maybe it'd be better to write out these ideas as a library and<br>
> implement a bunch of example codes for different approaches. Changing the<br>
> interfaces for exception handling code is subtle stuff!<br>
><br>
><br>
> On Jul 14, 2016 5:42 PM, "Oliver Charles" <<a href="javascript:;" onclick="_e(event, 'cvml', 'ollie@ocharles.org.uk')">ollie@ocharles.org.uk</a>> wrote:<br>
>><br>
>> data ExceptionHandler a = Rethrow | HandleException (IO a)<br>
>><br>
>> would be my offering of paint.<br>
>><br>
>> On Thu, Jul 14, 2016 at 9:52 PM David Feuer <<a href="javascript:;" onclick="_e(event, 'cvml', 'david.feuer@gmail.com')">david.feuer@gmail.com</a>> wrote:<br>
>>><br>
>>> Handle is no good because it clashes with file handles. How about<br>
>>> Reaction?<br>
>>><br>
>>><br>
>>> On Jul 14, 2016 1:53 PM, "Andreas Abel" <<a href="javascript:;" onclick="_e(event, 'cvml', 'andreas.abel@ifi.lmu.de')">andreas.abel@ifi.lmu.de</a>> wrote:<br>
>>>><br>
>>>> Maybe rather<br>
>>>><br>
>>>> data Handle a = Rethrow | Handle (IO a)<br>
>>>><br>
>>>> !?<br>
>>>> On 14.07.2016 19:12, David Feuer wrote:<br>
>>>>><br>
>>>>> That makes sense, I guess. Something like<br>
>>>>><br>
>>>>> data Handle a = Rethrow | Catch (IO a)<br>
>>>>><br>
>>>>> I suppose? My names are awful though.<br>
>>>>><br>
>>>>><br>
>>>>> On Jul 14, 2016 12:56 PM, "Oliver Charles" <<a href="javascript:;" onclick="_e(event, 'cvml', 'ollie@ocharles.org.uk')">ollie@ocharles.org.uk</a><br>
>>>>> <mailto:<a href="javascript:;" onclick="_e(event, 'cvml', 'ollie@ocharles.org.uk')">ollie@ocharles.org.uk</a>>> wrote:<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> On Tue, 12 Jul 2016, 1:23 a.m. David Feuer, <<a href="javascript:;" onclick="_e(event, 'cvml', 'david.feuer@gmail.com')">david.feuer@gmail.com</a><br>
>>>>> <mailto:<a href="javascript:;" onclick="_e(event, 'cvml', 'david.feuer@gmail.com')">david.feuer@gmail.com</a>>> wrote:<br>
>>>>><br>
>>>>> The catchJust and handleJust functions seem a bit weird and<br>
>>>>> unidiomatic.<br>
>>>>><br>
>>>>> catchJust<br>
>>>>> :: Exception e<br>
>>>>> => (e -> Maybe b) -- ^ Predicate to select<br>
>>>>> exceptions<br>
>>>>> -> IO a -- ^ Computation to run<br>
>>>>> -> (b -> IO a) -- ^ Handler<br>
>>>>> -> IO a<br>
>>>>> catchJust p a handler = catch a handler'<br>
>>>>> where handler' e = case p e of<br>
>>>>> Nothing -> throwIO e<br>
>>>>> Just b -> handler b<br>
>>>>><br>
>>>>> This takes two functions and then puts them together. I would<br>
>>>>> think the more natural API would be<br>
>>>>><br>
>>>>> catchMaybe :: Exception e => IO a -> (e -> Maybe (IO a)) -> IO<br>
>>>>> a<br>
>>>>> catchMaybe m handler = catch m handler' where<br>
>>>>> handler' e = fromMaybe (throwIO e) (handler e)<br>
>>>>><br>
>>>>> A point don't feel super strongly about, but feel I should raise,<br>
>>>>> is<br>
>>>>> that Nothing seems to be somewhat confusing. catchJust<br>
>>>>> (\FileNotFound -> Nothing) seems to suggest that if FileNotFound<br>
>>>>> occurs then nothing will happen, that is - the exception is<br>
>>>>> ignored.<br>
>>>>> However, that is not the case, rather than Nothing happening<br>
>>>>> something certainly happens - an exception is (re)thrown!<br>
>>>>><br>
>>>>> Whether or not this confusion is likely to happen in practice I<br>
>>>>> don't know, but it suggests a type isomorphic to Maybe is a better<br>
>>>>> fit.<br>
>>>>><br>
>>>>> Ollie<br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> Libraries mailing list<br>
>>>>> <a href="javascript:;" onclick="_e(event, 'cvml', 'Libraries@haskell.org')">Libraries@haskell.org</a><br>
>>>>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Andreas Abel <>< Du bist der geliebte Mensch.<br>
>>>><br>
>>>> Department of Computer Science and Engineering<br>
>>>> Chalmers and Gothenburg University, Sweden<br>
>>>><br>
>>>> <a href="javascript:;" onclick="_e(event, 'cvml', 'andreas.abel@gu.se')">andreas.abel@gu.se</a><br>
>>>> <a href="http://www2.tcs.ifi.lmu.de/~abel/" target="_blank">http://www2.tcs.ifi.lmu.de/~abel/</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="javascript:;" onclick="_e(event, 'cvml', 'Libraries@haskell.org')">Libraries@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="javascript:;" onclick="_e(event, 'cvml', 'Libraries@haskell.org')">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
><br>
</blockquote>