Copyright | (c) 2015-2016 Bryan O'Sullivan |
---|---|
License | BSD3 |
Maintainer | Bryan O'Sullivan <bos@serpentine.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Internal types and functions.
Note: all declarations in this module are unstable, and prone to being changed at any time.
- data IResult a
- data JSONPathElement
- type JSONPath = [JSONPathElement]
- (<?>) :: Parser a -> JSONPathElement -> Parser a
- formatError :: JSONPath -> String -> String
- ifromJSON :: FromJSON a => Value -> IResult a
- iparse :: (a -> Parser b) -> a -> IResult b
Documentation
The internal result of running a Parser
.
Monad IResult Source # | |
Functor IResult Source # | |
MonadFail IResult Source # | |
Applicative IResult Source # | |
Foldable IResult Source # | |
Traversable IResult Source # | |
Alternative IResult Source # | |
MonadPlus IResult Source # | |
Eq a => Eq (IResult a) Source # | |
Show a => Show (IResult a) Source # | |
Semigroup (IResult a) Source # | |
Monoid (IResult a) Source # | |
NFData a => NFData (IResult a) Source # | |
data JSONPathElement Source #
Elements of a JSON path used to describe the location of an error.
type JSONPath = [JSONPathElement] Source #
(<?>) :: Parser a -> JSONPathElement -> Parser a Source #
Add JSON Path context to a parser
When parsing a complex structure, it helps to annotate (sub)parsers with context, so that if an error occurs, you can find its location.
withObject "Person" $ \o -> Person <$> o .: "name" <?> Key "name" <*> o .: "age" <?> Key "age"
(Standard methods like '(.:)' already do this.)
With such annotations, if an error occurs, you will get a JSON Path location of that error.
Since 0.10
formatError :: JSONPath -> String -> String Source #
Annotate an error message with a JSONPath error location.