{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}

#ifdef TRUSTWORTHY
{-# LANGUAGE Trustworthy #-}
#endif

#include "lens-common.h"

-----------------------------------------------------------------------------
-- |
-- Module      :  Control.Exception.Lens
-- Copyright   :  (C) 2012-16 Edward Kmett
-- License     :  BSD-style (see the file LICENSE)
-- Maintainer  :  Edward Kmett <ekmett@gmail.com>
-- Stability   :  provisional
-- Portability :  Control.Exception
--
-- @Control.Exception@ provides an example of a large open hierarchy
-- that we can model with prisms and isomorphisms.
--
-- Additional combinators for working with 'IOException' results can
-- be found in "System.IO.Error.Lens".
--
-- The combinators in this module have been generalized to work with
-- 'MonadCatch' instead of just 'Prelude.IO'. This enables them to be used
-- more easily in 'Monad' transformer stacks.
----------------------------------------------------------------------------
module Control.Exception.Lens
  (
  -- * Handling
    catching, catching_
  , handling, handling_
  -- * Trying
  , trying, trying_
  -- * Throwing
  , throwing
  , throwing_
  , throwingM
  , throwingTo
  -- * Mapping
  , mappedException, mappedException'
  -- * Exceptions
  , exception
  , pattern Exception
  -- * Exception Handlers
  , Handleable(..)
  -- ** IOExceptions
  , AsIOException(..)
  , pattern IOException_
  -- ** Arithmetic Exceptions
  , AsArithException(..)
  , _Overflow, _Underflow, _LossOfPrecision, _DivideByZero, _Denormal
  , _RatioZeroDenominator
  , pattern ArithException_
  , pattern Overflow_
  , pattern Underflow_
  , pattern LossOfPrecision_
  , pattern DivideByZero_
  , pattern Denormal_
  , pattern RatioZeroDenominator_
  -- ** Array Exceptions
  , AsArrayException(..)
  , _IndexOutOfBounds
  , _UndefinedElement
  , pattern ArrayException_
  , pattern IndexOutOfBounds_
  , pattern UndefinedElement_
  -- ** Assertion Failed
  , AsAssertionFailed(..)
  , pattern AssertionFailed__
  , pattern AssertionFailed_
  -- ** Async Exceptions
  , AsAsyncException(..)
  , _StackOverflow
  , _HeapOverflow
  , _ThreadKilled
  , _UserInterrupt
  , pattern AsyncException_
  , pattern StackOverflow_
  , pattern HeapOverflow_
  , pattern ThreadKilled_
  , pattern UserInterrupt_
  -- ** Non-Termination
  , AsNonTermination(..)
  , pattern NonTermination__
  , pattern NonTermination_
  -- ** Nested Atomically
  , AsNestedAtomically(..)
  , pattern NestedAtomically__
  , pattern NestedAtomically_
  -- ** Blocked Indefinitely
  -- *** on MVar
  , AsBlockedIndefinitelyOnMVar(..)
  , pattern BlockedIndefinitelyOnMVar__
  , pattern BlockedIndefinitelyOnMVar_
  -- *** on STM
  , AsBlockedIndefinitelyOnSTM(..)
  , pattern BlockedIndefinitelyOnSTM__
  , pattern BlockedIndefinitelyOnSTM_
  -- ** Deadlock
  , AsDeadlock(..)
  , pattern Deadlock__
  , pattern Deadlock_
  -- ** No Such Method
  , AsNoMethodError(..)
  , pattern NoMethodError__
  , pattern NoMethodError_
  -- ** Pattern Match Failure
  , AsPatternMatchFail(..)
  , pattern PatternMatchFail__
  , pattern PatternMatchFail_
  -- ** Record
  , AsRecConError(..)
  , AsRecSelError(..)
  , AsRecUpdError(..)
  , pattern RecConError__
  , pattern RecConError_
  , pattern RecSelError__
  , pattern RecSelError_
  , pattern RecUpdError__
  , pattern RecUpdError_
  -- ** Error Call
  , AsErrorCall(..)
  , pattern ErrorCall__
  , pattern ErrorCall_
  -- ** Allocation Limit Exceeded
  , AsAllocationLimitExceeded(..)
  , pattern AllocationLimitExceeded__
  , pattern AllocationLimitExceeded_
  -- ** Type Error
  , AsTypeError(..)
  , pattern TypeError__
  , pattern TypeError_
#if MIN_VERSION_base(4,10,0)
  -- ** Compaction Failed
  , AsCompactionFailed(..)
  , pattern CompactionFailed__
  , pattern CompactionFailed_
#endif
  -- * Handling Exceptions
  , AsHandlingException(..)
  , pattern HandlingException__
  , pattern HandlingException_
  ) where

import Control.Applicative
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Catch as Catch
import Control.Exception as Exception hiding (try, tryJust, catchJust)
import Control.Lens
import Control.Lens.Internal.Exception
import Data.Monoid
import GHC.Conc (ThreadId)
import Prelude
  ( const, either, flip, id
  , (.)
  , Maybe(..), Either(..), String
  , Bool(..)
  )

-- $setup
-- >>> :set -XNoOverloadedStrings
-- >>> import Control.Lens
-- >>> import Control.Applicative
-- >>> :m + Control.Exception Control.Monad Data.List Prelude

------------------------------------------------------------------------------
-- Exceptions as Prisms
------------------------------------------------------------------------------

-- | Traverse the strongly typed t'Exception' contained in 'SomeException' where the type of your function matches
-- the desired t'Exception'.
--
-- @
-- 'exception' :: ('Applicative' f, t'Exception' a)
--           => (a -> f a) -> 'SomeException' -> f 'SomeException'
-- @
exception :: Exception a => Prism' SomeException a
exception :: forall a. Exception a => Prism' SomeException a
exception = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall e. Exception e => e -> SomeException
toException forall e. Exception e => SomeException -> Maybe e
fromException
{-# INLINE exception #-}

pattern Exception :: Exception a => a -> SomeException
pattern $bException :: forall e. Exception e => e -> SomeException
$mException :: forall {r} {a}.
Exception a =>
SomeException -> (a -> r) -> ((# #) -> r) -> r
Exception e <- (preview exception -> Just e) where
  Exception a
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall a. Exception a => Prism' SomeException a
exception a
e

------------------------------------------------------------------------------
-- Catching
------------------------------------------------------------------------------

-- | Catch exceptions that match a given t'Prism' (or any t'Fold', really).
--
-- >>> catching _AssertionFailed (assert False (return "uncaught")) $ \ _ -> return "caught"
-- "caught"
--
-- @
-- 'catching' :: 'MonadCatch' m => 'Prism'' 'SomeException' a     -> m r -> (a -> m r) -> m r
-- 'catching' :: 'MonadCatch' m => 'Lens'' 'SomeException' a      -> m r -> (a -> m r) -> m r
-- 'catching' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> m r -> (a -> m r) -> m r
-- 'catching' :: 'MonadCatch' m => 'Iso'' 'SomeException' a       -> m r -> (a -> m r) -> m r
-- 'catching' :: 'MonadCatch' m => t'Getter' 'SomeException' a    -> m r -> (a -> m r) -> m r
-- 'catching' :: 'MonadCatch' m => t'Fold' 'SomeException' a      -> m r -> (a -> m r) -> m r
-- @
catching :: MonadCatch m => Getting (First a) SomeException a -> m r -> (a -> m r) -> m r
catching :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> (a -> m r) -> m r
catching Getting (First a) SomeException a
l = forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b) -> m a -> (b -> m a) -> m a
catchJust (forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First a) SomeException a
l)
{-# INLINE catching #-}

-- | Catch exceptions that match a given t'Prism' (or any t'Getter'), discarding
-- the information about the match. This is particularly useful when you have
-- a @'Prism'' e ()@ where the result of the t'Prism' or t'Fold' isn't
-- particularly valuable, just the fact that it matches.
--
-- >>> catching_ _AssertionFailed (assert False (return "uncaught")) $ return "caught"
-- "caught"
--
-- @
-- 'catching_' :: 'MonadCatch' m => 'Prism'' 'SomeException' a     -> m r -> m r -> m r
-- 'catching_' :: 'MonadCatch' m => 'Lens'' 'SomeException' a      -> m r -> m r -> m r
-- 'catching_' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> m r -> m r -> m r
-- 'catching_' :: 'MonadCatch' m => 'Iso'' 'SomeException' a       -> m r -> m r -> m r
-- 'catching_' :: 'MonadCatch' m => t'Getter' 'SomeException' a    -> m r -> m r -> m r
-- 'catching_' :: 'MonadCatch' m => t'Fold' 'SomeException' a      -> m r -> m r -> m r
-- @
catching_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m r -> m r
catching_ :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m r -> m r
catching_ Getting (First a) SomeException a
l m r
a m r
b = forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b) -> m a -> (b -> m a) -> m a
catchJust (forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First a) SomeException a
l) m r
a (forall a b. a -> b -> a
const m r
b)
{-# INLINE catching_ #-}

------------------------------------------------------------------------------
-- Handling
------------------------------------------------------------------------------

-- | A version of 'catching' with the arguments swapped around; useful in
-- situations where the code for the handler is shorter.
--
-- >>> handling _NonTermination (\_ -> return "caught") $ throwIO NonTermination
-- "caught"
--
-- @
-- 'handling' :: 'MonadCatch' m => 'Prism'' 'SomeException' a     -> (a -> m r) -> m r -> m r
-- 'handling' :: 'MonadCatch' m => 'Lens'' 'SomeException' a      -> (a -> m r) -> m r -> m r
-- 'handling' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> (a -> m r) -> m r -> m r
-- 'handling' :: 'MonadCatch' m => 'Iso'' 'SomeException' a       -> (a -> m r) -> m r -> m r
-- 'handling' :: 'MonadCatch' m => t'Fold' 'SomeException' a      -> (a -> m r) -> m r -> m r
-- 'handling' :: 'MonadCatch' m => t'Getter' 'SomeException' a    -> (a -> m r) -> m r -> m r
-- @
handling :: MonadCatch m => Getting (First a) SomeException a -> (a -> m r) -> m r -> m r
handling :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> (a -> m r) -> m r -> m r
handling Getting (First a) SomeException a
l = forall a b c. (a -> b -> c) -> b -> a -> c
flip (forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> (a -> m r) -> m r
catching Getting (First a) SomeException a
l)
{-# INLINE handling #-}

-- | A version of 'catching_' with the arguments swapped around; useful in
-- situations where the code for the handler is shorter.
--
-- >>> handling_ _NonTermination (return "caught") $ throwIO NonTermination
-- "caught"
--
-- @
-- 'handling_' :: 'MonadCatch' m => 'Prism'' 'SomeException' a     -> m r -> m r -> m r
-- 'handling_' :: 'MonadCatch' m => 'Lens'' 'SomeException' a      -> m r -> m r -> m r
-- 'handling_' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> m r -> m r -> m r
-- 'handling_' :: 'MonadCatch' m => 'Iso'' 'SomeException' a       -> m r -> m r -> m r
-- 'handling_' :: 'MonadCatch' m => t'Getter' 'SomeException' a    -> m r -> m r -> m r
-- 'handling_' :: 'MonadCatch' m => t'Fold' 'SomeException' a      -> m r -> m r -> m r
-- @
handling_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m r -> m r
handling_ :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m r -> m r
handling_ Getting (First a) SomeException a
l = forall a b c. (a -> b -> c) -> b -> a -> c
flip (forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m r -> m r
catching_ Getting (First a) SomeException a
l)
{-# INLINE handling_ #-}

------------------------------------------------------------------------------
-- Trying
------------------------------------------------------------------------------

-- | A variant of 'Control.Exception.try' that takes a t'Prism' (or any t'Fold') to select which
-- exceptions are caught (c.f. 'Control.Exception.tryJust', 'Control.Exception.catchJust'). If the
-- t'Exception' does not match the predicate, it is re-thrown.
--
-- @
-- 'trying' :: 'MonadCatch' m => 'Prism''     'SomeException' a -> m r -> m ('Either' a r)
-- 'trying' :: 'MonadCatch' m => 'Lens''      'SomeException' a -> m r -> m ('Either' a r)
-- 'trying' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> m r -> m ('Either' a r)
-- 'trying' :: 'MonadCatch' m => 'Iso''       'SomeException' a -> m r -> m ('Either' a r)
-- 'trying' :: 'MonadCatch' m => t'Getter'    'SomeException' a -> m r -> m ('Either' a r)
-- 'trying' :: 'MonadCatch' m => t'Fold'      'SomeException' a -> m r -> m ('Either' a r)
-- @
trying :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Either a r)
trying :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m (Either a r)
trying Getting (First a) SomeException a
l = forall (m :: * -> *) e b a.
(MonadCatch m, Exception e) =>
(e -> Maybe b) -> m a -> m (Either b a)
tryJust (forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview Getting (First a) SomeException a
l)
{-# INLINE trying #-}

-- | A version of 'trying' that discards the specific exception thrown.
--
-- @
-- 'trying_' :: 'MonadCatch' m => 'Prism''     'SomeException' a -> m r -> m (Maybe r)
-- 'trying_' :: 'MonadCatch' m => 'Lens''      'SomeException' a -> m r -> m (Maybe r)
-- 'trying_' :: 'MonadCatch' m => 'Traversal'' 'SomeException' a -> m r -> m (Maybe r)
-- 'trying_' :: 'MonadCatch' m => 'Iso''       'SomeException' a -> m r -> m (Maybe r)
-- 'trying_' :: 'MonadCatch' m => t'Getter'    'SomeException' a -> m r -> m (Maybe r)
-- 'trying_' :: 'MonadCatch' m => t'Fold'      'SomeException' a -> m r -> m (Maybe r)
-- @
trying_ :: MonadCatch m => Getting (First a) SomeException a -> m r -> m (Maybe r)
trying_ :: forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m (Maybe r)
trying_ Getting (First a) SomeException a
l m r
m = forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview forall c a b. Prism (Either c a) (Either c b) a b
_Right forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` forall (m :: * -> *) a r.
MonadCatch m =>
Getting (First a) SomeException a -> m r -> m (Either a r)
trying Getting (First a) SomeException a
l m r
m
{-# INLINE trying_ #-}

------------------------------------------------------------------------------
-- Throwing
------------------------------------------------------------------------------

-- | Throw an t'Exception' described by a t'Prism'. Exceptions may be thrown from
-- purely functional code, but may only be caught within the 'Prelude.IO' 'Monad'.
--
-- @
-- 'throwing' l ≡ 'reviews' l 'throw'
-- @
--
-- @
-- 'throwing' :: 'Prism'' 'SomeException' t -> t -> r
-- 'throwing' :: 'Iso'' 'SomeException' t   -> t -> r
-- @
throwing :: AReview SomeException b -> b -> r
throwing :: forall b r. AReview SomeException b -> b -> r
throwing AReview SomeException b
l = forall b (m :: * -> *) t r.
MonadReader b m =>
AReview t b -> (t -> r) -> m r
reviews AReview SomeException b
l forall a e. Exception e => e -> a
Exception.throw
{-# INLINE throwing #-}

-- | Similar to 'throwing' but specialised for the common case of
--   error constructors with no arguments.
--
-- @
-- data MyError = Foo | Bar
-- makePrisms ''MyError
-- 'throwing_' _Foo :: 'Control.Monad.Error.Class.MonadError' MyError m => m a
-- @
throwing_ :: AReview SomeException () -> m x
throwing_ :: forall (m :: * -> *) x. AReview SomeException () -> m x
throwing_ AReview SomeException ()
l = forall b r. AReview SomeException b -> b -> r
throwing AReview SomeException ()
l ()
{-# INLINE throwing_ #-}

-- | A variant of 'throwing' that can only be used within the 'Prelude.IO' 'Monad'
-- (or any other 'MonadCatch' instance) to throw an t'Exception' described
-- by a t'Prism'.
--
-- Although 'throwingM' has a type that is a specialization of the type of
-- 'throwing', the two functions are subtly different:
--
-- @
-- 'throwing' l e \`seq\` x  ≡ 'throwing' e
-- 'throwingM' l e \`seq\` x ≡ x
-- @
--
-- The first example will cause the t'Exception' @e@ to be raised, whereas the
-- second one won't. In fact, 'throwingM' will only cause an t'Exception' to
-- be raised when it is used within the 'MonadCatch' instance. The 'throwingM'
-- variant should be used in preference to 'throwing' to raise an t'Exception'
-- within the 'Monad' because it guarantees ordering with respect to other
-- monadic operations, whereas 'throwing' does not.
--
-- @
-- 'throwingM' l ≡ 'reviews' l 'CatchIO.throw'
-- @
--
-- @
-- 'throwingM' :: 'MonadThrow' m => 'Prism'' 'SomeException' t -> t -> m r
-- 'throwingM' :: 'MonadThrow' m => 'Iso'' 'SomeException' t   -> t -> m r
-- @
throwingM :: MonadThrow m => AReview SomeException b -> b -> m r
throwingM :: forall (m :: * -> *) b r.
MonadThrow m =>
AReview SomeException b -> b -> m r
throwingM AReview SomeException b
l = forall b (m :: * -> *) t r.
MonadReader b m =>
AReview t b -> (t -> r) -> m r
reviews AReview SomeException b
l forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM
{-# INLINE throwingM #-}

-- | 'throwingTo' raises an t'Exception' specified by a t'Prism' in the target thread.
--
-- @
-- 'throwingTo' thread l ≡ 'reviews' l ('throwTo' thread)
-- @
--
-- @
-- 'throwingTo' :: 'ThreadId' -> 'Prism'' 'SomeException' t -> t -> m a
-- 'throwingTo' :: 'ThreadId' -> 'Iso'' 'SomeException' t   -> t -> m a
-- @
throwingTo :: MonadIO m => ThreadId -> AReview SomeException b -> b -> m ()
throwingTo :: forall (m :: * -> *) b.
MonadIO m =>
ThreadId -> AReview SomeException b -> b -> m ()
throwingTo ThreadId
tid AReview SomeException b
l = forall b (m :: * -> *) t r.
MonadReader b m =>
AReview t b -> (t -> r) -> m r
reviews AReview SomeException b
l (forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e. Exception e => ThreadId -> e -> IO ()
throwTo ThreadId
tid)
{-# INLINE throwingTo #-}

----------------------------------------------------------------------------
-- Mapping
----------------------------------------------------------------------------

-- | This t'Setter' can be used to purely map over the t'Exception's an
-- arbitrary expression might throw; it is a variant of 'mapException' in
-- the same way that 'mapped' is a variant of 'fmap'.
--
-- > 'mapException' ≡ 'over' 'mappedException'
--
-- This view that every Haskell expression can be regarded as carrying a bag
-- of t'Exception's is detailed in “A Semantics for Imprecise Exceptions” by
-- Peyton Jones & al. at PLDI ’99.
--
-- The following maps failed assertions to arithmetic overflow:
--
-- >>> handling _Overflow (\_ -> return "caught") $ assert False (return "uncaught") & mappedException %~ \ (AssertionFailed _) -> Overflow
-- "caught"
mappedException :: (Exception e, Exception e') => Setter s s e e'
mappedException :: forall e e' s. (Exception e, Exception e') => Setter s s e e'
mappedException = forall (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) a b s t.
(Profunctor p, Profunctor q, Settable f) =>
(p a b -> q s t) -> Optical p q f s t a b
sets forall e1 e2 a.
(Exception e1, Exception e2) =>
(e1 -> e2) -> a -> a
mapException
{-# INLINE mappedException #-}

-- | This is a type restricted version of 'mappedException', which avoids
-- the type ambiguity in the input t'Exception' when using 'set'.
--
-- The following maps any exception to arithmetic overflow:
--
-- >>> handling _Overflow (\_ -> return "caught") $ assert False (return "uncaught") & mappedException' .~ Overflow
-- "caught"
mappedException' :: Exception e' => Setter s s SomeException e'
mappedException' :: forall e' s. Exception e' => Setter s s SomeException e'
mappedException' = forall e e' s. (Exception e, Exception e') => Setter s s e e'
mappedException
{-# INLINE mappedException' #-}

----------------------------------------------------------------------------
-- IOException
----------------------------------------------------------------------------

-- | Exceptions that occur in the 'Prelude.IO' 'Monad'. An 'IOException' records a
-- more specific error type, a descriptive string and maybe the handle that was
-- used when the error was flagged.
--
-- Due to their richer structure relative to other exceptions, these have
-- a more carefully overloaded signature.
class AsIOException t where
  -- | Unfortunately the name 'GHC.IO.Exception.ioException' is taken by @base@ for
  -- throwing IOExceptions.
  --
  -- @
  -- '_IOException' :: 'Prism'' 'IOException' 'IOException'
  -- '_IOException' :: 'Prism'' 'SomeException' 'IOException'
  -- @
  --
  -- Many combinators for working with an 'IOException' are available
  -- in "System.IO.Error.Lens".
  _IOException :: Prism' t IOException

instance AsIOException IOException where
  _IOException :: Prism' IOException IOException
_IOException = forall a. a -> a
id
  {-# INLINE _IOException #-}

instance AsIOException SomeException where
  _IOException :: Prism' SomeException IOException
_IOException = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE _IOException #-}

pattern IOException_ :: AsIOException s => IOException -> s
pattern $bIOException_ :: forall s. AsIOException s => IOException -> s
$mIOException_ :: forall {r} {s}.
AsIOException s =>
s -> (IOException -> r) -> ((# #) -> r) -> r
IOException_ a <- (preview _IOException -> Just a) where
  IOException_ IOException
a = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsIOException t => Prism' t IOException
_IOException IOException
a

----------------------------------------------------------------------------
-- ArithException
----------------------------------------------------------------------------

-- | Arithmetic exceptions.
class AsArithException t where
  -- |
  -- @
  -- '_ArithException' :: 'Prism'' 'ArithException' 'ArithException'
  -- '_ArithException' :: 'Prism'' 'SomeException'  'ArithException'
  -- @
  _ArithException :: Prism' t ArithException

pattern ArithException_ :: AsArithException s => ArithException -> s
pattern $bArithException_ :: forall s. AsArithException s => ArithException -> s
$mArithException_ :: forall {r} {s}.
AsArithException s =>
s -> (ArithException -> r) -> ((# #) -> r) -> r
ArithException_ a <- (preview _ArithException -> Just a) where
  ArithException_ ArithException
a = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ArithException
_ArithException ArithException
a

instance AsArithException ArithException where
  _ArithException :: Prism' ArithException ArithException
_ArithException = forall a. a -> a
id
  {-# INLINE _ArithException #-}

instance AsArithException SomeException where
  _ArithException :: Prism' SomeException ArithException
_ArithException = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE _ArithException #-}

-- | Handle arithmetic '_Overflow'.
--
-- @
-- '_Overflow' ≡ '_ArithException' '.' '_Overflow'
-- @
--
-- @
-- '_Overflow' :: 'Prism'' 'ArithException' 'ArithException'
-- '_Overflow' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_Overflow :: AsArithException t => Prism' t ()
_Overflow :: forall t. AsArithException t => Prism' t ()
_Overflow = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
Overflow forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
Overflow = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _Overflow #-}

pattern Overflow_ :: AsArithException s => s
pattern $bOverflow_ :: forall s. AsArithException s => s
$mOverflow_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
Overflow_ <- (has _Overflow -> True) where
  Overflow_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_Overflow ()

-- | Handle arithmetic '_Underflow'.
--
-- @
-- '_Underflow' ≡ '_ArithException' '.' '_Underflow'
-- @
--
-- @
-- '_Underflow' :: 'Prism'' 'ArithException' 'ArithException'
-- '_Underflow' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_Underflow :: AsArithException t => Prism' t ()
_Underflow :: forall t. AsArithException t => Prism' t ()
_Underflow = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
Underflow forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
Underflow = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _Underflow #-}

pattern Underflow_ :: AsArithException s => s
pattern $bUnderflow_ :: forall s. AsArithException s => s
$mUnderflow_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
Underflow_ <- (has _Underflow -> True) where
  Underflow_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_Underflow ()

-- | Handle arithmetic loss of precision.
--
-- @
-- '_LossOfPrecision' ≡ '_ArithException' '.' '_LossOfPrecision'
-- @
--
-- @
-- '_LossOfPrecision' :: 'Prism'' 'ArithException' 'ArithException'
-- '_LossOfPrecision' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_LossOfPrecision :: AsArithException t => Prism' t ()
_LossOfPrecision :: forall t. AsArithException t => Prism' t ()
_LossOfPrecision = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
LossOfPrecision forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
LossOfPrecision = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _LossOfPrecision #-}

pattern LossOfPrecision_ :: AsArithException s => s
pattern $bLossOfPrecision_ :: forall s. AsArithException s => s
$mLossOfPrecision_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
LossOfPrecision_ <- (has _LossOfPrecision -> True) where
  LossOfPrecision_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_LossOfPrecision ()

-- | Handle division by zero.
--
-- @
-- '_DivideByZero' ≡ '_ArithException' '.' '_DivideByZero'
-- @
--
-- @
-- '_DivideByZero' :: 'Prism'' 'ArithException' 'ArithException'
-- '_DivideByZero' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_DivideByZero :: AsArithException t => Prism' t ()
_DivideByZero :: forall t. AsArithException t => Prism' t ()
_DivideByZero = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
DivideByZero forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
DivideByZero = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _DivideByZero #-}

pattern DivideByZero_ :: AsArithException s => s
pattern $bDivideByZero_ :: forall s. AsArithException s => s
$mDivideByZero_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
DivideByZero_ <- (has _DivideByZero -> True) where
  DivideByZero_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_DivideByZero ()

-- | Handle exceptional _Denormalized floating pure.
--
-- @
-- '_Denormal' ≡ '_ArithException' '.' '_Denormal'
-- @
--
-- @
-- '_Denormal' :: 'Prism'' 'ArithException' 'ArithException'
-- '_Denormal' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_Denormal :: AsArithException t => Prism' t ()
_Denormal :: forall t. AsArithException t => Prism' t ()
_Denormal = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
Denormal forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
Denormal = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _Denormal #-}

pattern Denormal_ :: AsArithException s => s
pattern $bDenormal_ :: forall s. AsArithException s => s
$mDenormal_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
Denormal_ <- (has _Denormal -> True) where
  Denormal_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_Denormal ()

-- |
--
-- @
-- '_RatioZeroDenominator' ≡ '_ArithException' '.' '_RatioZeroDenominator'
-- @
--
-- @
-- '_RatioZeroDenominator' :: 'Prism'' 'ArithException' 'ArithException'
-- '_RatioZeroDenominator' :: 'Prism'' 'SomeException'  'ArithException'
-- @
_RatioZeroDenominator :: AsArithException t => Prism' t ()
_RatioZeroDenominator :: forall t. AsArithException t => Prism' t ()
_RatioZeroDenominator = forall t. AsArithException t => Prism' t ArithException
_ArithException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArithException -> Either (f ArithException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (ArithException
RatioZeroDenominator forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: ArithException -> Either (f ArithException) ()
seta ArithException
RatioZeroDenominator = forall a b. b -> Either a b
Right ()
  seta ArithException
t        = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArithException
t)
{-# INLINE _RatioZeroDenominator #-}

pattern RatioZeroDenominator_ :: AsArithException s => s
pattern $bRatioZeroDenominator_ :: forall s. AsArithException s => s
$mRatioZeroDenominator_ :: forall {r} {s}.
AsArithException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
RatioZeroDenominator_ <- (has _RatioZeroDenominator -> True) where
  RatioZeroDenominator_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArithException t => Prism' t ()
_RatioZeroDenominator ()

----------------------------------------------------------------------------
-- ArrayException
----------------------------------------------------------------------------

-- | Exceptions generated by array operations.
class AsArrayException t where
  -- | Extract information about an 'ArrayException'.
  --
  -- @
  -- '_ArrayException' :: 'Prism'' 'ArrayException' 'ArrayException'
  -- '_ArrayException' :: 'Prism'' 'SomeException'  'ArrayException'
  -- @
  _ArrayException :: Prism' t ArrayException

instance AsArrayException ArrayException where
  _ArrayException :: Prism' ArrayException ArrayException
_ArrayException = forall a. a -> a
id
  {-# INLINE _ArrayException #-}

instance AsArrayException SomeException where
  _ArrayException :: Prism' SomeException ArrayException
_ArrayException = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE _ArrayException #-}

pattern ArrayException_ :: AsArrayException s => ArrayException -> s
pattern $bArrayException_ :: forall s. AsArrayException s => ArrayException -> s
$mArrayException_ :: forall {r} {s}.
AsArrayException s =>
s -> (ArrayException -> r) -> ((# #) -> r) -> r
ArrayException_ e <- (preview _ArrayException -> Just e) where
  ArrayException_ ArrayException
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArrayException t => Prism' t ArrayException
_ArrayException ArrayException
e

-- | An attempt was made to index an array outside its declared bounds.
--
-- @
-- '_IndexOutOfBounds' ≡ '_ArrayException' '.' '_IndexOutOfBounds'
-- @
--
-- @
-- '_IndexOutOfBounds' :: 'Prism'' 'ArrayException' 'String'
-- '_IndexOutOfBounds' :: 'Prism'' 'SomeException'  'String'
-- @
_IndexOutOfBounds :: AsArrayException t => Prism' t String
_IndexOutOfBounds :: forall t. AsArrayException t => Prism' t String
_IndexOutOfBounds = forall t. AsArrayException t => Prism' t ArrayException
_ArrayException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArrayException -> Either (f ArrayException) String
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> ArrayException
IndexOutOfBounds) where
  seta :: ArrayException -> Either (f ArrayException) String
seta (IndexOutOfBounds String
r) = forall a b. b -> Either a b
Right String
r
  seta ArrayException
t                    = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArrayException
t)
{-# INLINE _IndexOutOfBounds #-}

pattern IndexOutOfBounds_ :: AsArrayException s => String -> s
pattern $bIndexOutOfBounds_ :: forall s. AsArrayException s => String -> s
$mIndexOutOfBounds_ :: forall {r} {s}.
AsArrayException s =>
s -> (String -> r) -> ((# #) -> r) -> r
IndexOutOfBounds_ e <- (preview _IndexOutOfBounds -> Just e) where
  IndexOutOfBounds_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArrayException t => Prism' t String
_IndexOutOfBounds String
e

-- | An attempt was made to evaluate an element of an array that had not been initialized.
--
-- @
-- '_UndefinedElement' ≡ '_ArrayException' '.' '_UndefinedElement'
-- @
--
-- @
-- '_UndefinedElement' :: 'Prism'' 'ArrayException' 'String'
-- '_UndefinedElement' :: 'Prism'' 'SomeException'  'String'
-- @
_UndefinedElement :: AsArrayException t => Prism' t String
_UndefinedElement :: forall t. AsArrayException t => Prism' t String
_UndefinedElement = forall t. AsArrayException t => Prism' t ArrayException
_ArrayException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
ArrayException -> Either (f ArrayException) String
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> ArrayException
UndefinedElement) where
  seta :: ArrayException -> Either (f ArrayException) String
seta (UndefinedElement String
r) = forall a b. b -> Either a b
Right String
r
  seta ArrayException
t                    = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure ArrayException
t)
{-# INLINE _UndefinedElement #-}

pattern UndefinedElement_ :: AsArrayException s => String -> s
pattern $bUndefinedElement_ :: forall s. AsArrayException s => String -> s
$mUndefinedElement_ :: forall {r} {s}.
AsArrayException s =>
s -> (String -> r) -> ((# #) -> r) -> r
UndefinedElement_ e <- (preview _UndefinedElement -> Just e) where
  UndefinedElement_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsArrayException t => Prism' t String
_UndefinedElement String
e

----------------------------------------------------------------------------
-- AssertionFailed
----------------------------------------------------------------------------

-- | 'assert' was applied to 'Prelude.False'.
class AsAssertionFailed t where
  -- |
  -- @
  -- '__AssertionFailed' :: 'Prism'' 'AssertionFailed' 'AssertionFailed'
  -- '__AssertionFailed' :: 'Prism'' 'SomeException'   'AssertionFailed'
  -- @
  __AssertionFailed :: Prism' t AssertionFailed

  -- | This t'Exception' contains provides information about what assertion failed in the 'String'.
  --
  -- >>> handling _AssertionFailed (\ xs -> "caught" <$ guard ("<interactive>" `isInfixOf` xs) ) $ assert False (return "uncaught")
  -- "caught"
  --
  -- @
  -- '_AssertionFailed' :: 'Prism'' 'AssertionFailed' 'String'
  -- '_AssertionFailed' :: 'Prism'' 'SomeException'   'String'
  -- @
  _AssertionFailed :: Prism' t String
  _AssertionFailed = forall t. AsAssertionFailed t => Prism' t AssertionFailed
__AssertionFailedforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsAssertionFailed t => Prism' t String
_AssertionFailed
  {-# INLINE _AssertionFailed #-}

instance AsAssertionFailed AssertionFailed where
  __AssertionFailed :: Prism' AssertionFailed AssertionFailed
__AssertionFailed = forall a. a -> a
id
  {-# INLINE __AssertionFailed #-}

  _AssertionFailed :: Prism' AssertionFailed String
_AssertionFailed = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> AssertionFailed
AssertionFailed
  {-# INLINE _AssertionFailed #-}

instance AsAssertionFailed SomeException where
  __AssertionFailed :: Prism' SomeException AssertionFailed
__AssertionFailed = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __AssertionFailed #-}

pattern AssertionFailed__ :: AsAssertionFailed s => AssertionFailed -> s
pattern $bAssertionFailed__ :: forall s. AsAssertionFailed s => AssertionFailed -> s
$mAssertionFailed__ :: forall {r} {s}.
AsAssertionFailed s =>
s -> (AssertionFailed -> r) -> ((# #) -> r) -> r
AssertionFailed__ e <- (preview __AssertionFailed -> Just e) where
  AssertionFailed__ AssertionFailed
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAssertionFailed t => Prism' t AssertionFailed
__AssertionFailed AssertionFailed
e

pattern AssertionFailed_ :: AsAssertionFailed s => String -> s
pattern $bAssertionFailed_ :: forall s. AsAssertionFailed s => String -> s
$mAssertionFailed_ :: forall {r} {s}.
AsAssertionFailed s =>
s -> (String -> r) -> ((# #) -> r) -> r
AssertionFailed_ e <- (preview _AssertionFailed -> Just e) where
  AssertionFailed_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAssertionFailed t => Prism' t String
_AssertionFailed String
e

----------------------------------------------------------------------------
-- AsyncException
----------------------------------------------------------------------------

-- | Asynchronous exceptions.
class AsAsyncException t where
  -- | There are several types of 'AsyncException'.
  --
  -- @
  -- '_AsyncException' :: 'Equality'' 'AsyncException' 'AsyncException'
  -- '_AsyncException' :: 'Prism''    'SomeException'  'AsyncException'
  -- @
  _AsyncException :: Prism' t AsyncException

instance AsAsyncException AsyncException where
  _AsyncException :: Prism' AsyncException AsyncException
_AsyncException = forall a. a -> a
id
  {-# INLINE _AsyncException #-}

instance AsAsyncException SomeException where
  _AsyncException :: Prism' SomeException AsyncException
_AsyncException = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE _AsyncException #-}

pattern AsyncException_ :: AsAsyncException s => AsyncException -> s
pattern $bAsyncException_ :: forall s. AsAsyncException s => AsyncException -> s
$mAsyncException_ :: forall {r} {s}.
AsAsyncException s =>
s -> (AsyncException -> r) -> ((# #) -> r) -> r
AsyncException_ e <- (preview _AsyncException -> Just e) where
  AsyncException_ AsyncException
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAsyncException t => Prism' t AsyncException
_AsyncException AsyncException
e

-- | The current thread's stack exceeded its limit. Since an t'Exception' has
-- been raised, the thread's stack will certainly be below its limit again,
-- but the programmer should take remedial action immediately.
--
-- @
-- '_StackOverflow' :: 'Prism'' 'AsyncException' ()
-- '_StackOverflow' :: 'Prism'' 'SomeException'  ()
-- @
_StackOverflow :: AsAsyncException t => Prism' t ()
_StackOverflow :: forall t. AsAsyncException t => Prism' t ()
_StackOverflow = forall t. AsAsyncException t => Prism' t AsyncException
_AsyncException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
AsyncException -> Either (f AsyncException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (AsyncException
StackOverflow forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: AsyncException -> Either (f AsyncException) ()
seta AsyncException
StackOverflow = forall a b. b -> Either a b
Right ()
  seta AsyncException
t             = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure AsyncException
t)
{-# INLINE _StackOverflow #-}

pattern StackOverflow_ :: AsAsyncException s => s
pattern $bStackOverflow_ :: forall s. AsAsyncException s => s
$mStackOverflow_ :: forall {r} {s}.
AsAsyncException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
StackOverflow_ <- (has _StackOverflow -> True) where
  StackOverflow_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAsyncException t => Prism' t ()
_StackOverflow ()

-- | The program's heap is reaching its limit, and the program should take action
-- to reduce the amount of live data it has.
--
-- Notes:
--
-- * It is undefined which thread receives this t'Exception'.
--
-- * GHC currently does not throw 'HeapOverflow' exceptions.
--
-- @
-- '_HeapOverflow' :: 'Prism'' 'AsyncException' ()
-- '_HeapOverflow' :: 'Prism'' 'SomeException'  ()
-- @
_HeapOverflow :: AsAsyncException t => Prism' t ()
_HeapOverflow :: forall t. AsAsyncException t => Prism' t ()
_HeapOverflow = forall t. AsAsyncException t => Prism' t AsyncException
_AsyncException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
AsyncException -> Either (f AsyncException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (AsyncException
HeapOverflow forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: AsyncException -> Either (f AsyncException) ()
seta AsyncException
HeapOverflow = forall a b. b -> Either a b
Right ()
  seta AsyncException
t            = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure AsyncException
t)
{-# INLINE _HeapOverflow #-}

pattern HeapOverflow_ :: AsAsyncException s => s
pattern $bHeapOverflow_ :: forall s. AsAsyncException s => s
$mHeapOverflow_ :: forall {r} {s}.
AsAsyncException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
HeapOverflow_ <- (has _HeapOverflow -> True) where
  HeapOverflow_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAsyncException t => Prism' t ()
_HeapOverflow ()

-- | This t'Exception' is raised by another thread calling
-- 'Control.Concurrent.killThread', or by the system if it needs to terminate
-- the thread for some reason.
--
-- @
-- '_ThreadKilled' :: 'Prism'' 'AsyncException' ()
-- '_ThreadKilled' :: 'Prism'' 'SomeException'  ()
-- @
_ThreadKilled :: AsAsyncException t => Prism' t ()
_ThreadKilled :: forall t. AsAsyncException t => Prism' t ()
_ThreadKilled = forall t. AsAsyncException t => Prism' t AsyncException
_AsyncException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
AsyncException -> Either (f AsyncException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (AsyncException
ThreadKilled forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: AsyncException -> Either (f AsyncException) ()
seta AsyncException
ThreadKilled = forall a b. b -> Either a b
Right ()
  seta AsyncException
t            = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure AsyncException
t)
{-# INLINE _ThreadKilled #-}

pattern ThreadKilled_ :: AsAsyncException s => s
pattern $bThreadKilled_ :: forall s. AsAsyncException s => s
$mThreadKilled_ :: forall {r} {s}.
AsAsyncException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
ThreadKilled_ <- (has _ThreadKilled -> True) where
  ThreadKilled_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAsyncException t => Prism' t ()
_ThreadKilled ()

-- | This t'Exception' is raised by default in the main thread of the program when
-- the user requests to terminate the program via the usual mechanism(s)
-- (/e.g./ Control-C in the console).
--
-- @
-- '_UserInterrupt' :: 'Prism'' 'AsyncException' ()
-- '_UserInterrupt' :: 'Prism'' 'SomeException'  ()
-- @
_UserInterrupt :: AsAsyncException t => Prism' t ()
_UserInterrupt :: forall t. AsAsyncException t => Prism' t ()
_UserInterrupt = forall t. AsAsyncException t => Prism' t AsyncException
_AsyncException forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap forall {f :: * -> *}.
Applicative f =>
AsyncException -> Either (f AsyncException) ()
seta (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. a -> a
id forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) a b c.
Choice p =>
p a b -> p (Either c a) (Either c b)
right' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (p :: * -> * -> *) b c a.
Profunctor p =>
(b -> c) -> p a b -> p a c
rmap (AsyncException
UserInterrupt forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) where
  seta :: AsyncException -> Either (f AsyncException) ()
seta AsyncException
UserInterrupt = forall a b. b -> Either a b
Right ()
  seta AsyncException
t             = forall a b. a -> Either a b
Left  (forall (f :: * -> *) a. Applicative f => a -> f a
pure AsyncException
t)
{-# INLINE _UserInterrupt #-}

pattern UserInterrupt_ :: AsAsyncException s => s
pattern $bUserInterrupt_ :: forall s. AsAsyncException s => s
$mUserInterrupt_ :: forall {r} {s}.
AsAsyncException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
UserInterrupt_ <- (has _UserInterrupt -> True) where
  UserInterrupt_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAsyncException t => Prism' t ()
_UserInterrupt ()

----------------------------------------------------------------------------
-- AsyncException
----------------------------------------------------------------------------

-- | Thrown when the runtime system detects that the computation is guaranteed
-- not to terminate. Note that there is no guarantee that the runtime system
-- will notice whether any given computation is guaranteed to terminate or not.
class AsNonTermination t where
  -- |
  -- @
  -- '__NonTermination' :: 'Prism'' 'NonTermination' 'NonTermination'
  -- '__NonTermination' :: 'Prism'' 'SomeException'  'NonTermination'
  -- @
  __NonTermination :: Prism' t NonTermination

  -- | There is no additional information carried in a 'NonTermination' t'Exception'.
  --
  -- @
  -- '_NonTermination' :: 'Prism'' 'NonTermination' ()
  -- '_NonTermination' :: 'Prism'' 'SomeException'  ()
  -- @
  _NonTermination :: Prism' t ()
  _NonTermination = forall t. AsNonTermination t => Prism' t NonTermination
__NonTerminationforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsNonTermination t => Prism' t ()
_NonTermination
  {-# INLINE _NonTermination #-}

instance AsNonTermination NonTermination where
  __NonTermination :: Prism' NonTermination NonTermination
__NonTermination = forall a. a -> a
id
  {-# INLINE __NonTermination #-}

  _NonTermination :: Prism' NonTermination ()
_NonTermination = forall t. t -> Iso' t ()
trivial NonTermination
NonTermination
  {-# INLINE _NonTermination #-}

instance AsNonTermination SomeException where
  __NonTermination :: Prism' SomeException NonTermination
__NonTermination = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __NonTermination #-}

pattern NonTermination__ :: AsNonTermination s => NonTermination -> s
pattern $bNonTermination__ :: forall s. AsNonTermination s => NonTermination -> s
$mNonTermination__ :: forall {r} {s}.
AsNonTermination s =>
s -> (NonTermination -> r) -> ((# #) -> r) -> r
NonTermination__ e <- (preview __NonTermination -> Just e) where
  NonTermination__ NonTermination
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNonTermination t => Prism' t NonTermination
__NonTermination NonTermination
e

pattern NonTermination_ :: AsNonTermination s => s
pattern $bNonTermination_ :: forall s. AsNonTermination s => s
$mNonTermination_ :: forall {r} {s}.
AsNonTermination s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
NonTermination_ <- (has _NonTermination -> True) where
  NonTermination_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNonTermination t => Prism' t ()
_NonTermination ()

----------------------------------------------------------------------------
-- NestedAtomically
----------------------------------------------------------------------------

-- | Thrown when the program attempts to call atomically, from the
-- 'Control.Monad.STM' package, inside another call to atomically.
class AsNestedAtomically t where
  -- |
  -- @
  -- '__NestedAtomically' :: 'Prism'' 'NestedAtomically' 'NestedAtomically'
  -- '__NestedAtomically' :: 'Prism'' 'SomeException'    'NestedAtomically'
  -- @
  __NestedAtomically :: Prism' t NestedAtomically

  -- | There is no additional information carried in a 'NestedAtomically' t'Exception'.
  --
  -- @
  -- '_NestedAtomically' :: 'Prism'' 'NestedAtomically' ()
  -- '_NestedAtomically' :: 'Prism'' 'SomeException'    ()
  -- @
  _NestedAtomically :: Prism' t ()
  _NestedAtomically = forall t. AsNestedAtomically t => Prism' t NestedAtomically
__NestedAtomicallyforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsNestedAtomically t => Prism' t ()
_NestedAtomically
  {-# INLINE _NestedAtomically #-}

instance AsNestedAtomically NestedAtomically where
  __NestedAtomically :: Prism' NestedAtomically NestedAtomically
__NestedAtomically = forall a. a -> a
id
  {-# INLINE __NestedAtomically #-}

  _NestedAtomically :: Prism' NestedAtomically ()
_NestedAtomically = forall t. t -> Iso' t ()
trivial NestedAtomically
NestedAtomically
  {-# INLINE _NestedAtomically #-}

instance AsNestedAtomically SomeException where
  __NestedAtomically :: Prism' SomeException NestedAtomically
__NestedAtomically = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __NestedAtomically #-}

pattern NestedAtomically__ :: AsNestedAtomically s => NestedAtomically -> s
pattern $bNestedAtomically__ :: forall s. AsNestedAtomically s => NestedAtomically -> s
$mNestedAtomically__ :: forall {r} {s}.
AsNestedAtomically s =>
s -> (NestedAtomically -> r) -> ((# #) -> r) -> r
NestedAtomically__ e <- (preview __NestedAtomically -> Just e) where
  NestedAtomically__ NestedAtomically
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNestedAtomically t => Prism' t NestedAtomically
__NestedAtomically NestedAtomically
e

pattern NestedAtomically_ :: AsNestedAtomically s => s
pattern $bNestedAtomically_ :: forall s. AsNestedAtomically s => s
$mNestedAtomically_ :: forall {r} {s}.
AsNestedAtomically s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
NestedAtomically_ <- (has _NestedAtomically -> True) where
  NestedAtomically_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNestedAtomically t => Prism' t ()
_NestedAtomically ()

----------------------------------------------------------------------------
-- BlockedIndefinitelyOnMVar
----------------------------------------------------------------------------

-- | The thread is blocked on an 'Control.Concurrent.MVar.MVar', but there
-- are no other references to the 'Control.Concurrent.MVar.MVar' so it can't
-- ever continue.
class AsBlockedIndefinitelyOnMVar t where
  -- |
  -- @
  -- '__BlockedIndefinitelyOnMVar' :: 'Prism'' 'BlockedIndefinitelyOnMVar' 'BlockedIndefinitelyOnMVar'
  -- '__BlockedIndefinitelyOnMVar' :: 'Prism'' 'SomeException'             'BlockedIndefinitelyOnMVar'
  -- @
  __BlockedIndefinitelyOnMVar :: Prism' t BlockedIndefinitelyOnMVar

  -- | There is no additional information carried in a 'BlockedIndefinitelyOnMVar' t'Exception'.
  --
  -- @
  -- '_BlockedIndefinitelyOnMVar' :: 'Prism'' 'BlockedIndefinitelyOnMVar' ()
  -- '_BlockedIndefinitelyOnMVar' :: 'Prism'' 'SomeException'             ()
  -- @
  _BlockedIndefinitelyOnMVar :: Prism' t ()
  _BlockedIndefinitelyOnMVar = forall t.
AsBlockedIndefinitelyOnMVar t =>
Prism' t BlockedIndefinitelyOnMVar
__BlockedIndefinitelyOnMVarforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsBlockedIndefinitelyOnMVar t => Prism' t ()
_BlockedIndefinitelyOnMVar
  {-# INLINE _BlockedIndefinitelyOnMVar #-}

instance AsBlockedIndefinitelyOnMVar BlockedIndefinitelyOnMVar where
  __BlockedIndefinitelyOnMVar :: Prism' BlockedIndefinitelyOnMVar BlockedIndefinitelyOnMVar
__BlockedIndefinitelyOnMVar = forall a. a -> a
id
  {-# INLINE __BlockedIndefinitelyOnMVar #-}

  _BlockedIndefinitelyOnMVar :: Prism' BlockedIndefinitelyOnMVar ()
_BlockedIndefinitelyOnMVar = forall t. t -> Iso' t ()
trivial BlockedIndefinitelyOnMVar
BlockedIndefinitelyOnMVar
  {-# INLINE _BlockedIndefinitelyOnMVar #-}

instance AsBlockedIndefinitelyOnMVar SomeException where
  __BlockedIndefinitelyOnMVar :: Prism' SomeException BlockedIndefinitelyOnMVar
__BlockedIndefinitelyOnMVar = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __BlockedIndefinitelyOnMVar #-}

pattern BlockedIndefinitelyOnMVar__ :: AsBlockedIndefinitelyOnMVar s => BlockedIndefinitelyOnMVar -> s
pattern $bBlockedIndefinitelyOnMVar__ :: forall s.
AsBlockedIndefinitelyOnMVar s =>
BlockedIndefinitelyOnMVar -> s
$mBlockedIndefinitelyOnMVar__ :: forall {r} {s}.
AsBlockedIndefinitelyOnMVar s =>
s -> (BlockedIndefinitelyOnMVar -> r) -> ((# #) -> r) -> r
BlockedIndefinitelyOnMVar__ e <- (preview __BlockedIndefinitelyOnMVar -> Just e) where
  BlockedIndefinitelyOnMVar__ BlockedIndefinitelyOnMVar
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t.
AsBlockedIndefinitelyOnMVar t =>
Prism' t BlockedIndefinitelyOnMVar
__BlockedIndefinitelyOnMVar BlockedIndefinitelyOnMVar
e

pattern BlockedIndefinitelyOnMVar_ :: AsBlockedIndefinitelyOnMVar s => s
pattern $bBlockedIndefinitelyOnMVar_ :: forall s. AsBlockedIndefinitelyOnMVar s => s
$mBlockedIndefinitelyOnMVar_ :: forall {r} {s}.
AsBlockedIndefinitelyOnMVar s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
BlockedIndefinitelyOnMVar_ <- (has _BlockedIndefinitelyOnMVar -> True) where
  BlockedIndefinitelyOnMVar_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsBlockedIndefinitelyOnMVar t => Prism' t ()
_BlockedIndefinitelyOnMVar ()

----------------------------------------------------------------------------
-- BlockedIndefinitelyOnSTM
----------------------------------------------------------------------------

-- | The thread is waiting to retry an 'Control.Monad.STM.STM' transaction,
-- but there are no other references to any TVars involved, so it can't ever
-- continue.
class AsBlockedIndefinitelyOnSTM t where
  -- |
  -- @
  -- '__BlockedIndefinitelyOnSTM' :: 'Prism'' 'BlockedIndefinitelyOnSTM' 'BlockedIndefinitelyOnSTM'
  -- '__BlockedIndefinitelyOnSTM' :: 'Prism'' 'SomeException'            'BlockedIndefinitelyOnSTM'
  -- @
  __BlockedIndefinitelyOnSTM :: Prism' t BlockedIndefinitelyOnSTM

  -- | There is no additional information carried in a 'BlockedIndefinitelyOnSTM' t'Exception'.
  --
  -- @
  -- '_BlockedIndefinitelyOnSTM' :: 'Prism'' 'BlockedIndefinitelyOnSTM' ()
  -- '_BlockedIndefinitelyOnSTM' :: 'Prism'' 'SomeException'            ()
  -- @
  _BlockedIndefinitelyOnSTM :: Prism' t ()
  _BlockedIndefinitelyOnSTM = forall t.
AsBlockedIndefinitelyOnSTM t =>
Prism' t BlockedIndefinitelyOnSTM
__BlockedIndefinitelyOnSTMforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsBlockedIndefinitelyOnSTM t => Prism' t ()
_BlockedIndefinitelyOnSTM
  {-# INLINE _BlockedIndefinitelyOnSTM #-}

instance AsBlockedIndefinitelyOnSTM BlockedIndefinitelyOnSTM where
  __BlockedIndefinitelyOnSTM :: Prism' BlockedIndefinitelyOnSTM BlockedIndefinitelyOnSTM
__BlockedIndefinitelyOnSTM = forall a. a -> a
id
  {-# INLINE __BlockedIndefinitelyOnSTM #-}

  _BlockedIndefinitelyOnSTM :: Prism' BlockedIndefinitelyOnSTM ()
_BlockedIndefinitelyOnSTM = forall t. t -> Iso' t ()
trivial BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM
  {-# INLINE _BlockedIndefinitelyOnSTM #-}

instance AsBlockedIndefinitelyOnSTM SomeException where
  __BlockedIndefinitelyOnSTM :: Prism' SomeException BlockedIndefinitelyOnSTM
__BlockedIndefinitelyOnSTM = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __BlockedIndefinitelyOnSTM #-}

pattern BlockedIndefinitelyOnSTM__ :: AsBlockedIndefinitelyOnSTM s => BlockedIndefinitelyOnSTM -> s
pattern $bBlockedIndefinitelyOnSTM__ :: forall s.
AsBlockedIndefinitelyOnSTM s =>
BlockedIndefinitelyOnSTM -> s
$mBlockedIndefinitelyOnSTM__ :: forall {r} {s}.
AsBlockedIndefinitelyOnSTM s =>
s -> (BlockedIndefinitelyOnSTM -> r) -> ((# #) -> r) -> r
BlockedIndefinitelyOnSTM__ e <- (preview __BlockedIndefinitelyOnSTM -> Just e) where
  BlockedIndefinitelyOnSTM__ BlockedIndefinitelyOnSTM
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t.
AsBlockedIndefinitelyOnSTM t =>
Prism' t BlockedIndefinitelyOnSTM
__BlockedIndefinitelyOnSTM BlockedIndefinitelyOnSTM
e

pattern BlockedIndefinitelyOnSTM_ :: AsBlockedIndefinitelyOnSTM s => s
pattern $bBlockedIndefinitelyOnSTM_ :: forall s. AsBlockedIndefinitelyOnSTM s => s
$mBlockedIndefinitelyOnSTM_ :: forall {r} {s}.
AsBlockedIndefinitelyOnSTM s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
BlockedIndefinitelyOnSTM_ <- (has _BlockedIndefinitelyOnSTM -> True) where
  BlockedIndefinitelyOnSTM_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsBlockedIndefinitelyOnSTM t => Prism' t ()
_BlockedIndefinitelyOnSTM ()

----------------------------------------------------------------------------
-- Deadlock
----------------------------------------------------------------------------

-- | There are no runnable threads, so the program is deadlocked. The
-- 'Deadlock' t'Exception' is raised in the main thread only.
class AsDeadlock t where
  -- |
  -- @
  -- '__Deadlock' :: 'Prism'' 'Deadlock'      'Deadlock'
  -- '__Deadlock' :: 'Prism'' 'SomeException' 'Deadlock'
  -- @
  __Deadlock :: Prism' t Deadlock

  -- | There is no information carried in a 'Deadlock' t'Exception'.
  --
  -- @
  -- '_Deadlock' :: 'Prism'' 'Deadlock'      ()
  -- '_Deadlock' :: 'Prism'' 'SomeException' ()
  -- @
  _Deadlock :: Prism' t ()
  _Deadlock = forall t. AsDeadlock t => Prism' t Deadlock
__Deadlockforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsDeadlock t => Prism' t ()
_Deadlock
  {-# INLINE _Deadlock #-}

instance AsDeadlock Deadlock where
  __Deadlock :: Prism' Deadlock Deadlock
__Deadlock = forall a. a -> a
id
  {-# INLINE __Deadlock #-}

  _Deadlock :: Prism' Deadlock ()
_Deadlock = forall t. t -> Iso' t ()
trivial Deadlock
Deadlock
  {-# INLINE _Deadlock #-}

instance AsDeadlock SomeException where
  __Deadlock :: Prism' SomeException Deadlock
__Deadlock = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __Deadlock #-}

pattern Deadlock__ :: AsDeadlock s => Deadlock -> s
pattern $bDeadlock__ :: forall s. AsDeadlock s => Deadlock -> s
$mDeadlock__ :: forall {r} {s}.
AsDeadlock s =>
s -> (Deadlock -> r) -> ((# #) -> r) -> r
Deadlock__ e <- (preview __Deadlock -> Just e) where
  Deadlock__ Deadlock
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsDeadlock t => Prism' t Deadlock
__Deadlock Deadlock
e

pattern Deadlock_ :: AsDeadlock s => s
pattern $bDeadlock_ :: forall s. AsDeadlock s => s
$mDeadlock_ :: forall {r} {s}.
AsDeadlock s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
Deadlock_ <- (has _Deadlock -> True) where
  Deadlock_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsDeadlock t => Prism' t ()
_Deadlock ()

----------------------------------------------------------------------------
-- NoMethodError
----------------------------------------------------------------------------

-- | A class method without a definition (neither a default definition,
-- nor a definition in the appropriate instance) was called.
class AsNoMethodError t where
  -- |
  -- @
  -- '__NoMethodError' :: 'Prism'' 'NoMethodError' 'NoMethodError'
  -- '__NoMethodError' :: 'Prism'' 'SomeException' 'NoMethodError'
  -- @
  __NoMethodError :: Prism' t NoMethodError

  -- | Extract a description of the missing method.
  --
  -- @
  -- '_NoMethodError' :: 'Prism'' 'NoMethodError' 'String'
  -- '_NoMethodError' :: 'Prism'' 'SomeException' 'String'
  -- @
  _NoMethodError :: Prism' t String
  _NoMethodError = forall t. AsNoMethodError t => Prism' t NoMethodError
__NoMethodErrorforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsNoMethodError t => Prism' t String
_NoMethodError
  {-# INLINE _NoMethodError #-}

instance AsNoMethodError NoMethodError where
  __NoMethodError :: Prism' NoMethodError NoMethodError
__NoMethodError = forall a. a -> a
id
  {-# INLINE __NoMethodError #-}

  _NoMethodError :: Prism' NoMethodError String
_NoMethodError = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> NoMethodError
NoMethodError
  {-# INLINE _NoMethodError #-}

instance AsNoMethodError SomeException where
  __NoMethodError :: Prism' SomeException NoMethodError
__NoMethodError = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __NoMethodError #-}

pattern NoMethodError__ :: AsNoMethodError s => NoMethodError -> s
pattern $bNoMethodError__ :: forall s. AsNoMethodError s => NoMethodError -> s
$mNoMethodError__ :: forall {r} {s}.
AsNoMethodError s =>
s -> (NoMethodError -> r) -> ((# #) -> r) -> r
NoMethodError__ e <- (preview __NoMethodError -> Just e) where
  NoMethodError__ NoMethodError
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNoMethodError t => Prism' t NoMethodError
__NoMethodError NoMethodError
e

pattern NoMethodError_ :: AsNoMethodError s => String -> s
pattern $bNoMethodError_ :: forall s. AsNoMethodError s => String -> s
$mNoMethodError_ :: forall {r} {s}.
AsNoMethodError s =>
s -> (String -> r) -> ((# #) -> r) -> r
NoMethodError_ e <- (preview _NoMethodError -> Just e) where
  NoMethodError_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsNoMethodError t => Prism' t String
_NoMethodError String
e

----------------------------------------------------------------------------
-- PatternMatchFail
----------------------------------------------------------------------------

-- | A pattern match failed.
class AsPatternMatchFail t where
  -- |
  -- @
  -- '__PatternMatchFail' :: 'Prism'' 'PatternMatchFail' 'PatternMatchFail'
  -- '__PatternMatchFail' :: 'Prism'' 'SomeException'    'PatternMatchFail'
  -- @
  __PatternMatchFail :: Prism' t PatternMatchFail

  -- | Information about the source location of the pattern.
  --
  -- @
  -- '_PatternMatchFail' :: 'Prism'' 'PatternMatchFail' 'String'
  -- '_PatternMatchFail' :: 'Prism'' 'SomeException'    'String'
  -- @
  _PatternMatchFail :: Prism' t String
  _PatternMatchFail = forall t. AsPatternMatchFail t => Prism' t PatternMatchFail
__PatternMatchFailforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsPatternMatchFail t => Prism' t String
_PatternMatchFail
  {-# INLINE _PatternMatchFail #-}

instance AsPatternMatchFail PatternMatchFail where
  __PatternMatchFail :: Prism' PatternMatchFail PatternMatchFail
__PatternMatchFail = forall a. a -> a
id
  {-# INLINE __PatternMatchFail #-}

  _PatternMatchFail :: Prism' PatternMatchFail String
_PatternMatchFail = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> PatternMatchFail
PatternMatchFail
  {-# INLINE _PatternMatchFail #-}

instance AsPatternMatchFail SomeException where
  __PatternMatchFail :: Prism' SomeException PatternMatchFail
__PatternMatchFail = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __PatternMatchFail #-}

pattern PatternMatchFail__ :: AsPatternMatchFail s => PatternMatchFail -> s
pattern $bPatternMatchFail__ :: forall s. AsPatternMatchFail s => PatternMatchFail -> s
$mPatternMatchFail__ :: forall {r} {s}.
AsPatternMatchFail s =>
s -> (PatternMatchFail -> r) -> ((# #) -> r) -> r
PatternMatchFail__ e <- (preview __PatternMatchFail -> Just e) where
  PatternMatchFail__ PatternMatchFail
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsPatternMatchFail t => Prism' t PatternMatchFail
__PatternMatchFail PatternMatchFail
e

pattern PatternMatchFail_ :: AsPatternMatchFail s => String -> s
pattern $bPatternMatchFail_ :: forall s. AsPatternMatchFail s => String -> s
$mPatternMatchFail_ :: forall {r} {s}.
AsPatternMatchFail s =>
s -> (String -> r) -> ((# #) -> r) -> r
PatternMatchFail_ e <- (preview _PatternMatchFail -> Just e) where
  PatternMatchFail_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsPatternMatchFail t => Prism' t String
_PatternMatchFail String
e

----------------------------------------------------------------------------
-- RecConError
----------------------------------------------------------------------------

-- | An uninitialised record field was used.
class AsRecConError t where
  -- |
  -- @
  -- '__RecConError' :: 'Prism'' 'RecConError'   'RecConError'
  -- '__RecConError' :: 'Prism'' 'SomeException' 'RecConError'
  -- @
  __RecConError :: Prism' t RecConError

  -- | Information about the source location where the record was
  -- constructed.
  --
  -- @
  -- '_RecConError' :: 'Prism'' 'RecConError'   'String'
  -- '_RecConError' :: 'Prism'' 'SomeException' 'String'
  -- @
  _RecConError :: Prism' t String
  _RecConError = forall t. AsRecConError t => Prism' t RecConError
__RecConErrorforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsRecConError t => Prism' t String
_RecConError
  {-# INLINE _RecConError #-}

instance AsRecConError RecConError where
  __RecConError :: Prism' RecConError RecConError
__RecConError = forall a. a -> a
id
  {-# INLINE __RecConError #-}

  _RecConError :: Prism' RecConError String
_RecConError = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> RecConError
RecConError
  {-# INLINE _RecConError #-}

instance AsRecConError SomeException where
  __RecConError :: Prism' SomeException RecConError
__RecConError = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __RecConError #-}

pattern RecConError__ :: AsRecConError s => RecConError -> s
pattern $bRecConError__ :: forall s. AsRecConError s => RecConError -> s
$mRecConError__ :: forall {r} {s}.
AsRecConError s =>
s -> (RecConError -> r) -> ((# #) -> r) -> r
RecConError__ e <- (preview __RecConError -> Just e) where
  RecConError__ RecConError
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecConError t => Prism' t RecConError
__RecConError RecConError
e

pattern RecConError_ :: AsRecConError s => String -> s
pattern $bRecConError_ :: forall s. AsRecConError s => String -> s
$mRecConError_ :: forall {r} {s}.
AsRecConError s =>
s -> (String -> r) -> ((# #) -> r) -> r
RecConError_ e <- (preview _RecConError -> Just e) where
  RecConError_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecConError t => Prism' t String
_RecConError String
e

----------------------------------------------------------------------------
-- RecSelError
----------------------------------------------------------------------------

-- | A record selector was applied to a constructor without the appropriate
-- field. This can only happen with a datatype with multiple constructors,
-- where some fields are in one constructor but not another.
class AsRecSelError t where
  -- |
  -- @
  -- '__RecSelError' :: 'Prism'' 'RecSelError'   'RecSelError'
  -- '__RecSelError' :: 'Prism'' 'SomeException' 'RecSelError'
  -- @
  __RecSelError :: Prism' t RecSelError

  -- | Information about the source location where the record selection occurred.
  --
  -- @
  -- '_RecSelError' :: 'Prism'' 'RecSelError'   'String'
  -- '_RecSelError' :: 'Prism'' 'SomeException' 'String'
  -- @
  _RecSelError :: Prism' t String
  _RecSelError = forall t. AsRecSelError t => Prism' t RecSelError
__RecSelErrorforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsRecSelError t => Prism' t String
_RecSelError
  {-# INLINE _RecSelError #-}

instance AsRecSelError RecSelError where
  __RecSelError :: Prism' RecSelError RecSelError
__RecSelError = forall a. a -> a
id
  {-# INLINE __RecSelError #-}

  _RecSelError :: Prism' RecSelError String
_RecSelError = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> RecSelError
RecSelError
  {-# INLINE _RecSelError #-}

instance AsRecSelError SomeException where
  __RecSelError :: Prism' SomeException RecSelError
__RecSelError = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __RecSelError #-}

pattern RecSelError__ :: AsRecSelError s => RecSelError -> s
pattern $bRecSelError__ :: forall s. AsRecSelError s => RecSelError -> s
$mRecSelError__ :: forall {r} {s}.
AsRecSelError s =>
s -> (RecSelError -> r) -> ((# #) -> r) -> r
RecSelError__ e <- (preview __RecSelError -> Just e) where
  RecSelError__ RecSelError
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecSelError t => Prism' t RecSelError
__RecSelError RecSelError
e

pattern RecSelError_ :: AsRecSelError s => String -> s
pattern $bRecSelError_ :: forall s. AsRecSelError s => String -> s
$mRecSelError_ :: forall {r} {s}.
AsRecSelError s =>
s -> (String -> r) -> ((# #) -> r) -> r
RecSelError_ e <- (preview _RecSelError -> Just e) where
  RecSelError_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecSelError t => Prism' t String
_RecSelError String
e

----------------------------------------------------------------------------
-- RecUpdError
----------------------------------------------------------------------------

-- | A record update was performed on a constructor without the
-- appropriate field. This can only happen with a datatype with multiple
-- constructors, where some fields are in one constructor but not another.
class AsRecUpdError t where
  -- |
  -- @
  -- '__RecUpdError' :: 'Prism'' 'RecUpdError'   'RecUpdError'
  -- '__RecUpdError' :: 'Prism'' 'SomeException' 'RecUpdError'
  -- @
  __RecUpdError :: Prism' t RecUpdError

  -- | Information about the source location where the record was updated.
  --
  -- @
  -- '_RecUpdError' :: 'Prism'' 'RecUpdError'   'String'
  -- '_RecUpdError' :: 'Prism'' 'SomeException' 'String'
  -- @
  _RecUpdError :: Prism' t String
  _RecUpdError = forall t. AsRecUpdError t => Prism' t RecUpdError
__RecUpdErrorforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsRecUpdError t => Prism' t String
_RecUpdError
  {-# INLINE _RecUpdError #-}

instance AsRecUpdError RecUpdError where
  __RecUpdError :: Prism' RecUpdError RecUpdError
__RecUpdError = forall a. a -> a
id
  {-# INLINE __RecUpdError #-}

  _RecUpdError :: Prism' RecUpdError String
_RecUpdError = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> RecUpdError
RecUpdError
  {-# INLINE _RecUpdError #-}

instance AsRecUpdError SomeException where
  __RecUpdError :: Prism' SomeException RecUpdError
__RecUpdError = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __RecUpdError #-}

pattern RecUpdError__ :: AsRecUpdError s => RecUpdError -> s
pattern $bRecUpdError__ :: forall s. AsRecUpdError s => RecUpdError -> s
$mRecUpdError__ :: forall {r} {s}.
AsRecUpdError s =>
s -> (RecUpdError -> r) -> ((# #) -> r) -> r
RecUpdError__ e <- (preview __RecUpdError -> Just e) where
  RecUpdError__ RecUpdError
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecUpdError t => Prism' t RecUpdError
__RecUpdError RecUpdError
e

pattern RecUpdError_ :: AsRecUpdError s => String -> s
pattern $bRecUpdError_ :: forall s. AsRecUpdError s => String -> s
$mRecUpdError_ :: forall {r} {s}.
AsRecUpdError s =>
s -> (String -> r) -> ((# #) -> r) -> r
RecUpdError_ e <- (preview _RecUpdError -> Just e) where
  RecUpdError_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsRecUpdError t => Prism' t String
_RecUpdError String
e

----------------------------------------------------------------------------
-- ErrorCall
----------------------------------------------------------------------------

-- | This is thrown when the user calls 'Prelude.error'.
class AsErrorCall t where
  -- |
  -- @
  -- '__ErrorCall' :: 'Prism'' 'ErrorCall'     'ErrorCall'
  -- '__ErrorCall' :: 'Prism'' 'SomeException' 'ErrorCall'
  -- @
  __ErrorCall :: Prism' t ErrorCall

  -- | Retrieve the argument given to 'Prelude.error'.
  --
  -- 'ErrorCall' is isomorphic to a 'String'.
  --
  -- >>> catching _ErrorCall (error "touch down!") return
  -- "touch down!"
  --
  -- @
  -- '_ErrorCall' :: 'Prism'' 'ErrorCall'     'String'
  -- '_ErrorCall' :: 'Prism'' 'SomeException' 'String'
  -- @
  _ErrorCall :: Prism' t String
  _ErrorCall = forall t. AsErrorCall t => Prism' t ErrorCall
__ErrorCallforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsErrorCall t => Prism' t String
_ErrorCall
  {-# INLINE _ErrorCall #-}

instance AsErrorCall ErrorCall where
  __ErrorCall :: Prism' ErrorCall ErrorCall
__ErrorCall = forall a. a -> a
id
  {-# INLINE __ErrorCall #-}

  _ErrorCall :: Prism' ErrorCall String
_ErrorCall = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> ErrorCall
ErrorCall
  {-# INLINE _ErrorCall #-}

instance AsErrorCall SomeException where
  __ErrorCall :: Prism' SomeException ErrorCall
__ErrorCall = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __ErrorCall #-}

pattern ErrorCall__ :: AsErrorCall s => ErrorCall -> s
pattern $bErrorCall__ :: forall s. AsErrorCall s => ErrorCall -> s
$mErrorCall__ :: forall {r} {s}.
AsErrorCall s =>
s -> (ErrorCall -> r) -> ((# #) -> r) -> r
ErrorCall__ e <- (preview __ErrorCall -> Just e) where
  ErrorCall__ ErrorCall
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsErrorCall t => Prism' t ErrorCall
__ErrorCall ErrorCall
e

pattern ErrorCall_ :: AsErrorCall s => String -> s
pattern $bErrorCall_ :: forall s. AsErrorCall s => String -> s
$mErrorCall_ :: forall {r} {s}.
AsErrorCall s =>
s -> (String -> r) -> ((# #) -> r) -> r
ErrorCall_ e <- (preview _ErrorCall -> Just e) where
  ErrorCall_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsErrorCall t => Prism' t String
_ErrorCall String
e

----------------------------------------------------------------------------
-- AllocationLimitExceeded
----------------------------------------------------------------------------

-- | This thread has exceeded its allocation limit.
class AsAllocationLimitExceeded t where
  -- |
  -- @
  -- '__AllocationLimitExceeded' :: 'Prism'' 'AllocationLimitExceeded' 'AllocationLimitExceeded'
  -- '__AllocationLimitExceeded' :: 'Prism'' 'SomeException'           'AllocationLimitExceeded'
  -- @
  __AllocationLimitExceeded :: Prism' t AllocationLimitExceeded

  -- | There is no additional information carried in an
  -- 'AllocationLimitExceeded' t'Exception'.
  --
  -- @
  -- '_AllocationLimitExceeded' :: 'Prism'' 'AllocationLimitExceeded' ()
  -- '_AllocationLimitExceeded' :: 'Prism'' 'SomeException'           ()
  -- @
  _AllocationLimitExceeded :: Prism' t ()
  _AllocationLimitExceeded = forall t.
AsAllocationLimitExceeded t =>
Prism' t AllocationLimitExceeded
__AllocationLimitExceededforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsAllocationLimitExceeded t => Prism' t ()
_AllocationLimitExceeded
  {-# INLINE _AllocationLimitExceeded #-}

instance AsAllocationLimitExceeded AllocationLimitExceeded where
  __AllocationLimitExceeded :: Prism' AllocationLimitExceeded AllocationLimitExceeded
__AllocationLimitExceeded = forall a. a -> a
id
  {-# INLINE __AllocationLimitExceeded #-}

  _AllocationLimitExceeded :: Prism' AllocationLimitExceeded ()
_AllocationLimitExceeded = forall t. t -> Iso' t ()
trivial AllocationLimitExceeded
AllocationLimitExceeded
  {-# INLINE _AllocationLimitExceeded #-}

instance AsAllocationLimitExceeded SomeException where
  __AllocationLimitExceeded :: Prism' SomeException AllocationLimitExceeded
__AllocationLimitExceeded = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __AllocationLimitExceeded #-}

pattern AllocationLimitExceeded__ :: AsAllocationLimitExceeded s => AllocationLimitExceeded -> s
pattern $bAllocationLimitExceeded__ :: forall s.
AsAllocationLimitExceeded s =>
AllocationLimitExceeded -> s
$mAllocationLimitExceeded__ :: forall {r} {s}.
AsAllocationLimitExceeded s =>
s -> (AllocationLimitExceeded -> r) -> ((# #) -> r) -> r
AllocationLimitExceeded__ e <- (preview __AllocationLimitExceeded -> Just e) where
  AllocationLimitExceeded__ AllocationLimitExceeded
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t.
AsAllocationLimitExceeded t =>
Prism' t AllocationLimitExceeded
__AllocationLimitExceeded AllocationLimitExceeded
e

pattern AllocationLimitExceeded_ :: AsAllocationLimitExceeded s => s
pattern $bAllocationLimitExceeded_ :: forall s. AsAllocationLimitExceeded s => s
$mAllocationLimitExceeded_ :: forall {r} {s}.
AsAllocationLimitExceeded s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
AllocationLimitExceeded_ <- (has _AllocationLimitExceeded -> True) where
  AllocationLimitExceeded_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsAllocationLimitExceeded t => Prism' t ()
_AllocationLimitExceeded ()

----------------------------------------------------------------------------
-- TypeError
----------------------------------------------------------------------------

-- | An expression that didn't typecheck during compile time was called.
-- This is only possible with @-fdefer-type-errors@.
class AsTypeError t where
  -- |
  -- @
  -- '__TypeError' :: 'Prism'' 'TypeError'     'TypeError'
  -- '__TypeError' :: 'Prism'' 'SomeException' 'TypeError'
  -- @
  __TypeError :: Prism' t TypeError

  -- | Details about the failed type check.
  --
  -- @
  -- '_TypeError' :: 'Prism'' 'TypeError'     'String'
  -- '_TypeError' :: 'Prism'' 'SomeException' 'String'
  -- @
  _TypeError :: Prism' t String
  _TypeError = forall t. AsTypeError t => Prism' t TypeError
__TypeErrorforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsTypeError t => Prism' t String
_TypeError
  {-# INLINE _TypeError #-}

instance AsTypeError TypeError where
  __TypeError :: Prism' TypeError TypeError
__TypeError = forall a. a -> a
id
  {-# INLINE __TypeError #-}

  _TypeError :: Prism' TypeError String
_TypeError = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> TypeError
TypeError
  {-# INLINE _TypeError #-}

instance AsTypeError SomeException where
  __TypeError :: Prism' SomeException TypeError
__TypeError = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __TypeError #-}

pattern TypeError__ :: AsTypeError s => TypeError -> s
pattern $bTypeError__ :: forall s. AsTypeError s => TypeError -> s
$mTypeError__ :: forall {r} {s}.
AsTypeError s =>
s -> (TypeError -> r) -> ((# #) -> r) -> r
TypeError__ e <- (preview __TypeError -> Just e) where
  TypeError__ TypeError
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsTypeError t => Prism' t TypeError
__TypeError TypeError
e

pattern TypeError_ :: AsTypeError s => String -> s
pattern $bTypeError_ :: forall s. AsTypeError s => String -> s
$mTypeError_ :: forall {r} {s}.
AsTypeError s =>
s -> (String -> r) -> ((# #) -> r) -> r
TypeError_ e <- (preview _TypeError -> Just e) where
  TypeError_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsTypeError t => Prism' t String
_TypeError String
e

#if MIN_VERSION_base(4,10,0)
----------------------------------------------------------------------------
-- CompactionFailed
----------------------------------------------------------------------------

-- | Compaction found an object that cannot be compacted.
-- Functions cannot be compacted, nor can mutable objects or pinned objects.
class AsCompactionFailed t where
  -- |
  -- @
  -- '__CompactionFailed' :: 'Prism'' 'CompactionFailed' 'CompactionFailed'
  -- '__CompactionFailed' :: 'Prism'' 'SomeException'    'CompactionFailed'
  -- @
  __CompactionFailed :: Prism' t CompactionFailed

  -- | Information about why a compaction failed.
  --
  -- @
  -- '_CompactionFailed' :: 'Prism'' 'CompactionFailed' 'String'
  -- '_CompactionFailed' :: 'Prism'' 'SomeException'    'String'
  -- @
  _CompactionFailed :: Prism' t String
  _CompactionFailed = forall t. AsCompactionFailed t => Prism' t CompactionFailed
__CompactionFailedforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsCompactionFailed t => Prism' t String
_CompactionFailed
  {-# INLINE _CompactionFailed #-}

instance AsCompactionFailed CompactionFailed where
  __CompactionFailed :: Prism' CompactionFailed CompactionFailed
__CompactionFailed = forall a. a -> a
id
  {-# INLINE __CompactionFailed #-}

  _CompactionFailed :: Prism' CompactionFailed String
_CompactionFailed = forall s t.
Rewrapping s t =>
(Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
_Wrapping String -> CompactionFailed
CompactionFailed
  {-# INLINE _CompactionFailed #-}

instance AsCompactionFailed SomeException where
  __CompactionFailed :: Prism' SomeException CompactionFailed
__CompactionFailed = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __CompactionFailed #-}

pattern CompactionFailed__ :: AsCompactionFailed s => CompactionFailed -> s
pattern $bCompactionFailed__ :: forall s. AsCompactionFailed s => CompactionFailed -> s
$mCompactionFailed__ :: forall {r} {s}.
AsCompactionFailed s =>
s -> (CompactionFailed -> r) -> ((# #) -> r) -> r
CompactionFailed__ e <- (preview __CompactionFailed -> Just e) where
  CompactionFailed__ CompactionFailed
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsCompactionFailed t => Prism' t CompactionFailed
__CompactionFailed CompactionFailed
e

pattern CompactionFailed_ :: AsCompactionFailed s => String -> s
pattern $bCompactionFailed_ :: forall s. AsCompactionFailed s => String -> s
$mCompactionFailed_ :: forall {r} {s}.
AsCompactionFailed s =>
s -> (String -> r) -> ((# #) -> r) -> r
CompactionFailed_ e <- (preview _CompactionFailed -> Just e) where
  CompactionFailed_ String
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsCompactionFailed t => Prism' t String
_CompactionFailed String
e
#endif

------------------------------------------------------------------------------
-- HandlingException
------------------------------------------------------------------------------

-- | This t'Exception' is thrown by @lens@ when the user somehow manages to rethrow
-- an internal 'HandlingException'.
class AsHandlingException t where
  -- |
  -- @
  -- '__HandlingException' :: 'Prism'' 'HandlingException' 'HandlingException'
  -- '__HandlingException' :: 'Prism'' 'SomeException'     'HandlingException'
  -- @
  __HandlingException :: Prism' t HandlingException

  -- | There is no information carried in a 'HandlingException'.
  --
  -- @
  -- '_HandlingException' :: 'Prism'' 'HandlingException' ()
  -- '_HandlingException' :: 'Prism'' 'SomeException'     ()
  -- @
  _HandlingException :: Prism' t ()
  _HandlingException = forall t. AsHandlingException t => Prism' t HandlingException
__HandlingExceptionforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall t. AsHandlingException t => Prism' t ()
_HandlingException
  {-# INLINE _HandlingException #-}

instance AsHandlingException HandlingException where
  __HandlingException :: Prism' HandlingException HandlingException
__HandlingException = forall a. a -> a
id
  {-# INLINE __HandlingException #-}

  _HandlingException :: Prism' HandlingException ()
_HandlingException = forall t. t -> Iso' t ()
trivial HandlingException
HandlingException
  {-# INLINE _HandlingException #-}

instance AsHandlingException SomeException where
  __HandlingException :: Prism' SomeException HandlingException
__HandlingException = forall a. Exception a => Prism' SomeException a
exception
  {-# INLINE __HandlingException #-}

pattern HandlingException__ :: AsHandlingException s => HandlingException -> s
pattern $bHandlingException__ :: forall s. AsHandlingException s => HandlingException -> s
$mHandlingException__ :: forall {r} {s}.
AsHandlingException s =>
s -> (HandlingException -> r) -> ((# #) -> r) -> r
HandlingException__ e <- (preview __HandlingException -> Just e) where
  HandlingException__ HandlingException
e = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsHandlingException t => Prism' t HandlingException
__HandlingException HandlingException
e

pattern HandlingException_ :: AsHandlingException s => s
pattern $bHandlingException_ :: forall s. AsHandlingException s => s
$mHandlingException_ :: forall {r} {s}.
AsHandlingException s =>
s -> ((# #) -> r) -> ((# #) -> r) -> r
HandlingException_ <- (has _HandlingException -> True) where
  HandlingException_ = forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review forall t. AsHandlingException t => Prism' t ()
_HandlingException ()

------------------------------------------------------------------------------
-- Helper Functions
------------------------------------------------------------------------------

trivial :: t -> Iso' t ()
trivial :: forall t. t -> Iso' t ()
trivial t
t = forall a b. a -> b -> a
const () forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
`iso` forall a b. a -> b -> a
const t
t