| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
ReWire.Error
Synopsis
- data SyntaxErrorT ex (m :: Type -> Type) a
- data AstError
- data Warning = Warning !Annote !Text
- type Label = (Annote, Text)
- class Monad m => MonadError e (m :: Type -> Type) | m -> e
- mark :: (MonadState AstError m, Annotation an) => an -> m ()
- failAt :: (MonadError AstError m, Annotation an) => an -> Text -> m a
- failAt' :: (MonadError (ex, AstError) m, Annotation an) => ex -> an -> Text -> m a
- failAtWith :: (MonadError AstError m, Annotation an) => an -> Text -> [Label] -> [Text] -> m a
- failInternal :: (MonadError AstError m, Annotation an) => an -> Text -> m a
- relocateErr :: Annotation an => an -> AstError -> AstError
- relocatingTo :: (MonadError AstError m, Annotation an) => an -> m a -> m a
- relocatingNoLocTo :: (MonadError AstError m, Annotation an) => an -> m a -> m a
- failNowhere :: (PutMsg ex, Monad m, MonadState ex m, MonadError ex m) => Text -> m a
- warnAt :: (MonadError AstError m, MonadIO m, Annotation an) => Config -> an -> Text -> m ()
- filePath :: FilePath -> Annote
- printError :: MonadIO m => [FilePath] -> AstError -> m ()
- runSyntaxError :: Monad m => SyntaxErrorT AstError m a -> m (Either AstError a)
- class PutMsg a where
Documentation
data SyntaxErrorT ex (m :: Type -> Type) a Source #
The point of the newtype and all the annoying boilerplate is to redefine the "fail" method of the Monad and MonadFail typeclasses.
Instances
An error: a primary location and message, plus optional secondary labelled locations and suggested-fix hints.
A non-fatal diagnostic: printed to stderr when emitted (see warnAt),
or promoted to an AstError under -Werror.
type Label = (Annote, Text) Source #
A secondary location with an explanatory note, attached to an error to point at a related part of the source (e.g. "first defined here").
class Monad m => MonadError e (m :: Type -> Type) | m -> e #
The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information and
the monad type constructor.
It is common to use as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the Either StringMonadError class.
You can also define your own error type and/or use a monad type constructor
other than or Either String.
In these cases you will have to explicitly define instances of the Either IOErrorMonadError
class.
(If you are using the deprecated Control.Monad.Error or
Control.Monad.Trans.Error, you may also have to define an Error instance.)
Minimal complete definition
Instances
| MonadError IOException IO | |
Defined in Control.Monad.Error.Class | |
| MonadError () Maybe | Since: mtl-2.2.2 |
Defined in Control.Monad.Error.Class | |
| MonadError e m => MonadError e (Free m) | |
Defined in Control.Monad.Free | |
| MonadError e (Either e) | |
Defined in Control.Monad.Error.Class | |
| MonadError e m => MonadError e (ResourceT m) | |
Defined in Control.Monad.Trans.Resource.Internal Methods throwError :: e -> ResourceT m a # catchError :: ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a # | |
| MonadError e m => MonadError e (MaybeT m) | |
Defined in Control.Monad.Error.Class | |
| (Functor f, MonadError e m) => MonadError e (FreeT f m) | |
Defined in Control.Monad.Trans.Free Methods throwError :: e -> FreeT f m a # catchError :: FreeT f m a -> (e -> FreeT f m a) -> FreeT f m a # | |
| (Monoid w, MonadError e m) => MonadError e (AccumT w m) | Since: mtl-2.3 |
Defined in Control.Monad.Error.Class Methods throwError :: e -> AccumT w m a # catchError :: AccumT w m a -> (e -> AccumT w m a) -> AccumT w m a # | |
| Monad m => MonadError e (ExceptT e m) | Since: mtl-2.2 |
Defined in Control.Monad.Error.Class Methods throwError :: e -> ExceptT e m a # catchError :: ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a # | |
| MonadError e m => MonadError e (IdentityT m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> IdentityT m a # catchError :: IdentityT m a -> (e -> IdentityT m a) -> IdentityT m a # | |
| MonadError e m => MonadError e (ReaderT r m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> ReaderT r m a # catchError :: ReaderT r m a -> (e -> ReaderT r m a) -> ReaderT r m a # | |
| MonadError e m => MonadError e (StateT s m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> StateT s m a # catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a # | |
| MonadError e m => MonadError e (StateT s m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> StateT s m a # catchError :: StateT s m a -> (e -> StateT s m a) -> StateT s m a # | |
| (Monoid w, MonadError e m) => MonadError e (WriterT w m) | Since: mtl-2.3 |
Defined in Control.Monad.Error.Class Methods throwError :: e -> WriterT w m a # catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a # | |
| (Monoid w, MonadError e m) => MonadError e (WriterT w m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> WriterT w m a # catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a # | |
| (Monoid w, MonadError e m) => MonadError e (WriterT w m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> WriterT w m a # catchError :: WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a # | |
| Monad m => MonadError ex (SyntaxErrorT ex m) Source # | |
Defined in ReWire.Error Methods throwError :: ex -> SyntaxErrorT ex m a # catchError :: SyntaxErrorT ex m a -> (ex -> SyntaxErrorT ex m a) -> SyntaxErrorT ex m a # | |
| MonadError e m => MonadError e (ConduitT i o m) | |
Defined in Data.Conduit.Internal.Conduit Methods throwError :: e -> ConduitT i o m a # catchError :: ConduitT i o m a -> (e -> ConduitT i o m a) -> ConduitT i o m a # | |
| (Monoid w, MonadError e m) => MonadError e (RWST r w s m) | Since: mtl-2.3 |
Defined in Control.Monad.Error.Class Methods throwError :: e -> RWST r w s m a # catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a # | |
| (Monoid w, MonadError e m) => MonadError e (RWST r w s m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> RWST r w s m a # catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a # | |
| (Monoid w, MonadError e m) => MonadError e (RWST r w s m) | |
Defined in Control.Monad.Error.Class Methods throwError :: e -> RWST r w s m a # catchError :: RWST r w s m a -> (e -> RWST r w s m a) -> RWST r w s m a # | |
| MonadError e m => MonadError e (Pipe l i o u m) | |
Defined in Data.Conduit.Internal.Pipe Methods throwError :: e -> Pipe l i o u m a # catchError :: Pipe l i o u m a -> (e -> Pipe l i o u m a) -> Pipe l i o u m a # | |
mark :: (MonadState AstError m, Annotation an) => an -> m () Source #
failAt :: (MonadError AstError m, Annotation an) => an -> Text -> m a Source #
failAt' :: (MonadError (ex, AstError) m, Annotation an) => ex -> an -> Text -> m a Source #
Like failAt, but include an extra bit of data on failure.
failAtWith :: (MonadError AstError m, Annotation an) => an -> Text -> [Label] -> [Text] -> m a Source #
Like failAt, but attach secondary labelled locations and/or hints.
failInternal :: (MonadError AstError m, Annotation an) => an -> Text -> m a Source #
Report a violated internal invariant: a bug in rwc itself, not a problem with the user's program. Rendered with a "please report it" hint so the message can't be mistaken for a complaint about the user's code.
relocateErr :: Annotation an => an -> AstError -> AstError Source #
Re-point a diagnostic at a fallback location when it has none, or when it resolves to a different source file than the fallback — typically because the error surfaced inside inlined library code while compiling a user definition. The original location, when it had one, is kept as a secondary note so the expansion site stays visible.
relocatingTo :: (MonadError AstError m, Annotation an) => an -> m a -> m a Source #
Run an action, relocating any error it raises to the given fallback
location (see relocateErr).
relocatingNoLocTo :: (MonadError AstError m, Annotation an) => an -> m a -> m a Source #
failNowhere :: (PutMsg ex, Monad m, MonadState ex m, MonadError ex m) => Text -> m a Source #
warnAt :: (MonadError AstError m, MonadIO m, Annotation an) => Config -> an -> Text -> m () Source #
Emit a warning: printed to stderr immediately (so it isn't lost if a later pass fails), suppressed by -w, or promoted to an error by -Werror (which therefore fails on the *first* warning).
printError :: MonadIO m => [FilePath] -> AstError -> m () Source #
Print an error to stderr, GHC-style, with a source excerpt and a caret under the offending region (plus any secondary "note" blocks) when the files can be found on the load path.
runSyntaxError :: Monad m => SyntaxErrorT AstError m a -> m (Either AstError a) Source #