| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
KDL.Decoder.Internal.DecodeM
Contents
Synopsis
- module KDL.Decoder.Internal.Error
- data DecodeM a
- type DecodeHints = [BaseDecodeError]
- runDecodeM :: DecodeM a -> Either DecodeError a
- decodeThrow :: DecodeErrorKind -> DecodeM a
- failM :: Text -> DecodeM a
- mapErrors :: (BaseDecodeError -> BaseDecodeError) -> DecodeM a -> DecodeM a
- addContext :: Span -> ContextItem -> DecodeM a -> DecodeM a
- discardHints :: DecodeM a -> DecodeM a
Decoding errors
module KDL.Decoder.Internal.Error
DecodeM monad
The monad that returns either a DecodeError or a result of type a.
Constructors
| DecodeM_Found a DecodeHints | |
| DecodeM_Fail (NonEmpty BaseDecodeError) |
type DecodeHints = [BaseDecodeError] Source #
Hints to provide additional context in a future error after a successful branch.
Take this motivating example: a node takes an arbitrary number of string args. If you pass some strings then a number, it'll successfully parse up to the number and return success, only for the node to fail later with "unexpected argument: 123". But the true error was "unexpected number, expected string".
runDecodeM :: DecodeM a -> Either DecodeError a Source #
Run a DecodeM action and return the result or the deepest error found.
decodeThrow :: DecodeErrorKind -> DecodeM a Source #
Throw an error.
mapErrors :: (BaseDecodeError -> BaseDecodeError) -> DecodeM a -> DecodeM a Source #
addContext :: Span -> ContextItem -> DecodeM a -> DecodeM a Source #
Add context to all errors that occur in the given action.
discardHints :: DecodeM a -> DecodeM a Source #
Discard hints after validating that an error context is successful.