-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Provides API for enriching errors with contexts -- -- Please see the README on Github at -- https://github.com/mtesseract/error-context#readme @package error-context @version 0.1.2.0 -- | Provides an API for enriching errors with contexts. module Control.Error.Context -- | Encapsulates the error context — essentially a stack of Text -- values. data ErrorContext ErrorContext :: [Text] -> ErrorContext -- | Data type implementing MonadErrorContext. data ErrorContextT m a -- | Monad type class providing contextualized errors. class (Monad m, MonadThrow m) => MonadErrorContext m errorContextCollect :: MonadErrorContext m => m ErrorContext withErrorContext :: MonadErrorContext m => Text -> m a -> m a -- | Boundles an error with an ErrorContext. data ErrorWithContext e ErrorWithContext :: ErrorContext -> e -> ErrorWithContext e -- | Unwrap an ErrorContextT. Exceptions of type e thrown -- in the provided action via throwM will cause an -- ErrorWithContext e exception to be propagated upwards. runErrorContextT :: ErrorContextT m a -> m a -- | Enrich an error value with an error context. errorContextualize :: MonadErrorContext m => e -> m (ErrorWithContext e) -- | Forgets the context from an enriched error. errorContextForget :: ErrorWithContext e -> e -- | Dump an error with context to stdout. errorWithContextDump :: (Show e, MonadIO m) => ErrorWithContext e -> m () -- | Like catch, but the handler is required to be context-unaware. -- Is also able to catch exceptions with context, in which case the -- context will be forgotten before the exception will be provided to the -- handler. catchWithoutContext :: forall a e m. (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a -- | Like catch, but the handler is required to be context-aware. Is -- also able to catch exceptions of type e (without context). catchWithContext :: (MonadCatch m, Exception e) => m a -> (ErrorWithContext e -> m a) -> m a -- | Context aware version of catchAny. catchAnyWithContext :: MonadCatch m => m a -> (ErrorWithContext SomeException -> m a) -> m a -- | Context aware version of catchAny. catchAnyWithoutContext :: MonadCatch m => m a -> (SomeException -> m a) -> m a ensureExceptionContext :: (MonadCatch m, MonadErrorContext m) => m a -> m a tryAnyWithContext :: MonadCatch m => m a -> m (Either (ErrorWithContext SomeException) a) tryAnyWithoutContext :: MonadCatch m => m a -> m (Either SomeException a) tryWithContext :: (MonadCatch m, Exception e) => m a -> m (Either (ErrorWithContext e) a) tryWithoutContext :: (MonadCatch m, Exception e) => m a -> m (Either e a) instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Error.Context.ErrorContextT m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Error.Context.ErrorContextT m) instance Control.Monad.Trans.Class.MonadTrans Control.Error.Context.ErrorContextT instance GHC.Base.Monad m => GHC.Base.Monad (Control.Error.Context.ErrorContextT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Error.Context.ErrorContextT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Error.Context.ErrorContextT m) instance GHC.Show.Show e => GHC.Show.Show (Control.Error.Context.ErrorWithContext e) instance GHC.Classes.Eq Control.Error.Context.ErrorContext instance GHC.Show.Show Control.Error.Context.ErrorContext instance (Control.Monad.Catch.MonadCatch m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Error.Context.ErrorContextT m) instance Control.Monad.Catch.MonadThrow m => Control.Error.Context.MonadErrorContext (Control.Error.Context.ErrorContextT m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Error.Context.ErrorContextT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Error.Context.ErrorContextT m) instance (Control.Monad.Catch.MonadCatch m, Control.Monad.Trans.Resource.Internal.MonadResource m) => Control.Monad.Trans.Resource.Internal.MonadResource (Control.Error.Context.ErrorContextT m) instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Error.Context.ErrorContextT m) instance GHC.Base.Functor Control.Error.Context.ErrorWithContext instance GHC.Exception.Exception e => GHC.Exception.Exception (Control.Error.Context.ErrorWithContext e)