Copyright | ©2020 James Alexander Feldman-Crough |
---|---|
License | MPL-2.0 |
Maintainer | alex@fldcr.com |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Error a
- = Custom a
- | ParseError Key String
- | Required Key
- | ExpectedTag TagKind Key
- | ExpectedParagraph
- | ExpectedText
- | ExpectedBreak
- | EmptyMatch
- | Group (Maybe Location) (ErrorSet a)
- data TagKind
- data ErrorSet e
- type Error' = Error Void
- type ErrorSet' = ErrorSet Void
- type IsError e = (Exception e, Hashable e, Eq e)
- type MonadErrors e = MonadError (ErrorSet e)
- singleError :: Hashable e => Error e -> ErrorSet e
- customError :: Hashable e => e -> ErrorSet e
- throwError1 :: Hashable e => MonadErrors e m => Error e -> m a
- allErrors :: ErrorSet e -> NonEmpty (Error e)
- attachLocation :: (IsError e, MonadErrors e m, HasLocation l) => l -> m a -> m a
- class Monad m => MonadError e (m :: Type -> Type) | m -> e where
- throwError :: e -> m a
- catchError :: m a -> (e -> m a) -> m a
Documentation
Enumerates the errors thrown when
Custom a | A custom error, allowing extensibility. |
ParseError Key String | Thrown when parsing a setting fails. |
Required Key | Thrown when a setting was required to be set, but wasn't provided. |
ExpectedTag TagKind Key | Thrown when matching against a |
ExpectedParagraph | Thrown when matching against paragraph and an unexpected node was encountered. |
ExpectedText | Thrown when matching against text and an unexpected node was encountered. |
ExpectedBreak | Thrown when matching against an explicit break and an unexpected node was encountered. |
EmptyMatch | Thrown when a match has no cases to check against. |
Group (Maybe Location) (ErrorSet a) | Used to group a set of errors thrown at the same point in a tree. If a location is available, we attach it for debugging. |
Instances
A marker class for marking which type of tag ExpectedTag
was expecting.
Instances
Eq TagKind Source # | |
Show TagKind Source # | |
Generic TagKind Source # | |
Hashable TagKind Source # | |
Defined in Prosidy.Compile.Error | |
type Rep TagKind Source # | |
Defined in Prosidy.Compile.Error type Rep TagKind = D1 ('MetaData "TagKind" "Prosidy.Compile.Error" "prosidyc-0.1.0.0-inplace" 'False) (C1 ('MetaCons "BlockKind" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InlineKind" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LiteralKind" 'PrefixI 'False) (U1 :: Type -> Type))) |
A non-empty set of errors.
type IsError e = (Exception e, Hashable e, Eq e) Source #
A constraint alias for errors throwable in a context admitting a
MonadErrors
instance.
type MonadErrors e = MonadError (ErrorSet e) Source #
A contraint alias for types returning at least one error.
throwError1 :: Hashable e => MonadErrors e m => Error e -> m a Source #
Throw a single error.
allErrors :: ErrorSet e -> NonEmpty (Error e) Source #
Return the set of errors in an ErrorSet
as a non-empty list.
attachLocation :: (IsError e, MonadErrors e m, HasLocation l) => l -> m a -> m a Source #
Group errors together, attaching a location if one is available.
class Monad m => MonadError e (m :: Type -> Type) | m -> e where #
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
IOError
MonadError
class.
(If you are using the deprecated Control.Monad.Error or
Control.Monad.Trans.Error, you may also have to define an Error
instance.)
throwError :: e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: m a -> (e -> m a) -> m a #
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handler
where the action
functions can call throwError
.
Note that handler
and the do-block must have the same return type.