[GHC] #16301: Additions to Control.Exception: withException, displaySomeExceptionType

GHC ghc-devs at haskell.org
Sun Feb 10 16:54:42 UTC 2019


#16301: Additions to Control.Exception: withException, displaySomeExceptionType
-------------------------------------+-------------------------------------
           Reporter:  dsf            |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.6.3
  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:
-------------------------------------+-------------------------------------
 Requires RankNTypes though.

 {{{#!haskell
 -- | Apply a function to whatever @Exception@ type is inside a
 -- @SomeException at .
 withException :: forall r. (forall e. Exception e => e -> r) ->
 SomeException -> r
 withException f (SomeException e) = f e

 -- | Use 'withException' to obtain the exception's type name.
 displaySomeExceptionType :: SomeException -> String
 displaySomeExceptionType = withException (show . typeOf)
 }}}

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


More information about the ghc-tickets mailing list