
#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@. 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