packages feed

papa-0.7.0: src/Papa/Lens/Control/Exception.hs

{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}

-- | Exceptions as optics: a prism into 'Control.Exception.SomeException' for
-- each exception type of base ('_IOException', '_ArithException',
-- '_ErrorCall', '_ThreadKilled', …, and 'exception' for any type), and the
-- combinators that catch through a prism ('catching', 'handling', 'trying')
-- or throw in a monad through one ('throwingM', 'throwingTo').
--
-- > trying _IOException (throwIO (userError "u"))
--
-- 'catching', 'handling' and 'trying' catch what their prism matches, and
-- match an asynchronous exception if the prism does: through
-- '_ThreadKilled', '_AsyncException' or @'exception' \@SomeException@ they
-- catch a 'Papa.Base.Control.Exception.ThreadKilled', unlike
-- 'Papa.Base.Control.Exception.catch'. Through the prism of a synchronous
-- exception type they never do.
--
-- The classes of their constraints, 'MonadThrow', 'MonadCatch' and
-- 'MonadMask' (from the @exceptions@ package), are exported without their
-- methods: their @catch@, @try@ and @mask@ are not "Papa"'s.
--
-- Not exported: @throwing@ and @throwing_@, which throw from pure code (they
-- are in "Papa.Unsafe.Exception"), and @mappedException@ and
-- @mappedException'@, which rewrite the exceptions that pure code throws.
--
-- @since 0.7.0
module Papa.Lens.Control.Exception (
  module P,
  MonadThrow,
  MonadCatch,
  MonadMask,
) where

import Control.Monad.Catch (MonadCatch, MonadMask, MonadThrow)

import Control.Exception.Lens as P hiding (
  mappedException,
  mappedException',
  throwing,
  throwing_,
 )