[GHC] #12886: Proposal for throwLeft and throwLeftIO in Control.Exception

GHC ghc-devs at haskell.org
Sun Nov 27 20:54:23 UTC 2016


#12886: Proposal for throwLeft and throwLeftIO in Control.Exception
-------------------------------------+-------------------------------------
           Reporter:  yfeldblum      |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.0.1
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 There already exist some functions to translate between `Maybe` and
 `Exception`, and between `Either` and `Exception` in the module
 `Control.Exception`.

 Given an API like:
 {{{#!hs
 data MyException --...
 instance Exception MyException --...
 myUsefulFunction :: a -> b -> c -> Either MyException d
 myUsefulAction :: a -> b -> c -> IO (Either MyException d)
 }}}

 It sometimes the case that calling code that cannot sensibly handle `Left`
 results directly.

 This proposal is to add standard library functions that let calling code
 easily to turn `Left` results into thrown runtime exceptions, which might
 be caught and handled further up the call stack.

 {{{#!hs
 throwLeft :: Exception e => Either e a -> a
 throwLeftIO :: Exception e => Either e a -> IO a
 }}}

 Note that examples of functions named `throwLeft` may be found in the
 wild:
 https://www.stackage.org/lts-7.10/hoogle?q=throwLeft.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12886>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list