Discussion: add more idiomatic versions of catchJust and/or handleJust

David Feuer david.feuer at gmail.com
Fri Jul 15 17:50:39 UTC 2016


No one is proposing removing or changing the current functions. Maybe you
should re-read the thread. Unnamed people who don't voice their own
opinions don't count for much.

On Jul 15, 2016 10:46 AM, "Carter Schonwald" <carter.schonwald at gmail.com>
wrote:

> Respectfully I disagree.
>
> You are pushing a breaking change to functionality in the base exception
> Api without
> a) demonstrating the Api is better
>  b) understanding the impact on preexisting code that would needlessly
> break
> c) without doing a prototype outside of base to demonstrate that this
> alternative is better both in terms of the underlying library complexity
> and how the resulting application complexity changes.
>
> I am voicing an opinion other readers on the libraries list have on this
> matter but are too polite or wise to air this feedback publicly.
>
> The onus is on the proposer to demonstrate validity.
>
> Cheers
> -Carter
>
> On Friday, July 15, 2016, David Feuer <david.feuer at gmail.com> wrote:
>
>> You are very welcome to do so if you don't think further discussion will
>> be useful. Those who feel otherwise may continue to discuss it.
>>
>> On Jul 15, 2016 9:23 AM, "Carter Schonwald" <carter.schonwald at gmail.com>
>> wrote:
>>
>>> 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
>>>
>>> On Friday, July 15, 2016, David Thomas <davidleothomas at gmail.com> wrote:
>>>
>>>> I kinda like "ExceptionDisposition" for the type, no particular ideas
>>>> on the constructors.  Offered only in the spirit of tossing out ideas
>>>> - feel free to ignore me if it's not helpful :)
>>>>
>>>> On Thu, Jul 14, 2016 at 3:20 PM, Carter Schonwald
>>>> <carter.schonwald at gmail.com> wrote:
>>>> > At this point maybe it'd be better to write out these ideas as a
>>>> library and
>>>> > implement a bunch of example codes for different approaches.
>>>> Changing the
>>>> > interfaces for exception handling code is subtle stuff!
>>>> >
>>>> >
>>>> > On Jul 14, 2016 5:42 PM, "Oliver Charles" <ollie at ocharles.org.uk>
>>>> wrote:
>>>> >>
>>>> >> data ExceptionHandler a = Rethrow | HandleException (IO a)
>>>> >>
>>>> >> would be my offering of paint.
>>>> >>
>>>> >> On Thu, Jul 14, 2016 at 9:52 PM David Feuer <david.feuer at gmail.com>
>>>> wrote:
>>>> >>>
>>>> >>> Handle is no good because it clashes with file handles. How about
>>>> >>> Reaction?
>>>> >>>
>>>> >>>
>>>> >>> On Jul 14, 2016 1:53 PM, "Andreas Abel" <andreas.abel at ifi.lmu.de>
>>>> wrote:
>>>> >>>>
>>>> >>>> Maybe rather
>>>> >>>>
>>>> >>>>   data Handle a = Rethrow | Handle (IO a)
>>>> >>>>
>>>> >>>> !?
>>>> >>>> On 14.07.2016 19:12, David Feuer wrote:
>>>> >>>>>
>>>> >>>>> That makes sense, I guess. Something like
>>>> >>>>>
>>>> >>>>> data Handle a = Rethrow | Catch (IO a)
>>>> >>>>>
>>>> >>>>> I suppose? My names are awful though.
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> On Jul 14, 2016 12:56 PM, "Oliver Charles" <ollie at ocharles.org.uk
>>>> >>>>> <mailto:ollie at ocharles.org.uk>> wrote:
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>     On Tue, 12 Jul 2016, 1:23 a.m. David Feuer, <
>>>> david.feuer at gmail.com
>>>> >>>>>     <mailto:david.feuer at gmail.com>> wrote:
>>>> >>>>>
>>>> >>>>>         The catchJust and handleJust functions seem a bit weird
>>>> and
>>>> >>>>>         unidiomatic.
>>>> >>>>>
>>>> >>>>>         catchJust
>>>> >>>>>                  :: Exception e
>>>> >>>>>                  => (e -> Maybe b)         -- ^ Predicate to
>>>> select
>>>> >>>>>         exceptions
>>>> >>>>>                  -> IO a                   -- ^ Computation to run
>>>> >>>>>                  -> (b -> IO a)            -- ^ Handler
>>>> >>>>>                  -> IO a
>>>> >>>>>         catchJust p a handler = catch a handler'
>>>> >>>>>            where handler' e = case p e of
>>>> >>>>>                                  Nothing -> throwIO e
>>>> >>>>>                                  Just b  -> handler b
>>>> >>>>>
>>>> >>>>>         This takes two functions and then puts them together. I
>>>> would
>>>> >>>>>         think the more natural API would be
>>>> >>>>>
>>>> >>>>>         catchMaybe :: Exception e => IO a -> (e -> Maybe (IO a))
>>>> -> IO
>>>> >>>>> a
>>>> >>>>>         catchMaybe m handler = catch m handler' where
>>>> >>>>>            handler' e = fromMaybe (throwIO e) (handler e)
>>>> >>>>>
>>>> >>>>>     A point don't feel super strongly about, but feel I should
>>>> raise,
>>>> >>>>> is
>>>> >>>>>     that Nothing seems to be somewhat confusing. catchJust
>>>> >>>>>     (\FileNotFound -> Nothing) seems to suggest that if
>>>> FileNotFound
>>>> >>>>>     occurs then nothing will happen, that is - the exception is
>>>> >>>>> ignored.
>>>> >>>>>     However, that is not the case, rather than Nothing happening
>>>> >>>>>     something certainly happens - an exception is (re)thrown!
>>>> >>>>>
>>>> >>>>>     Whether or not this confusion is likely to happen in practice
>>>> I
>>>> >>>>>     don't know, but it suggests a type isomorphic to Maybe is a
>>>> better
>>>> >>>>> fit.
>>>> >>>>>
>>>> >>>>>     Ollie
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> _______________________________________________
>>>> >>>>> Libraries mailing list
>>>> >>>>> Libraries at haskell.org
>>>> >>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>> >>>>>
>>>> >>>>
>>>> >>>>
>>>> >>>> --
>>>> >>>> Andreas Abel  <><      Du bist der geliebte Mensch.
>>>> >>>>
>>>> >>>> Department of Computer Science and Engineering
>>>> >>>> Chalmers and Gothenburg University, Sweden
>>>> >>>>
>>>> >>>> andreas.abel at gu.se
>>>> >>>> http://www2.tcs.ifi.lmu.de/~abel/
>>>> >>
>>>> >>
>>>> >> _______________________________________________
>>>> >> Libraries mailing list
>>>> >> Libraries at haskell.org
>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>> >>
>>>> >
>>>> > _______________________________________________
>>>> > Libraries mailing list
>>>> > Libraries at haskell.org
>>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>> >
>>>>
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160715/e98fac9f/attachment.html>


More information about the Libraries mailing list