Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Minimal parser definition.
Synopsis
- newtype ParserT (st :: ZeroBitType) e a = ParserT {
- runParserT# :: ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
- type Parser = ParserT PureMode
- type ParserIO = ParserT IOMode
- type ParserST s = ParserT (STMode s)
- type Res# (st :: ZeroBitType) e a = (# st, ResI# e a #)
- pattern OK# :: (st :: ZeroBitType) -> a -> Addr# -> Res# st e a
- pattern Err# :: (st :: ZeroBitType) -> e -> Res# st e a
- pattern Fail# :: (st :: ZeroBitType) -> Res# st e a
- type ResI# e a = (# (# a, Addr# #) | (# #) | (# e #) #)
- (<|>) :: ParserT st e a -> ParserT st e a -> ParserT st e a
Parser
newtype ParserT (st :: ZeroBitType) e a Source #
ParserT st e a
is a parser with a state token type st
, an error type
e
and a return type a
. The different state token types support
different embedded effects; see Parser
, ParserIO
and ParserST
below.
ParserT | |
|
Instances
MonadIO (ParserIO e) Source # | |
Defined in FlatParse.Basic.Parser | |
Alternative (ParserT st e) Source # | By default, parser choice |
Applicative (ParserT st e) Source # | |
Defined in FlatParse.Basic.Parser | |
Functor (ParserT st e) Source # | |
Monad (ParserT st e) Source # | |
MonadPlus (ParserT st e) Source # | |
Result
type Res# (st :: ZeroBitType) e a = (# st, ResI# e a #) Source #
pattern OK# :: (st :: ZeroBitType) -> a -> Addr# -> Res# st e a Source #
Res#
constructor for a successful parse.
Contains the return value and a pointer to the rest of the input buffer,
plus a state token.
pattern Err# :: (st :: ZeroBitType) -> e -> Res# st e a Source #
Res#
constructor for errors which are by default non-recoverable.
Contains the error, plus a state token.
pattern Fail# :: (st :: ZeroBitType) -> Res# st e a Source #
Res#
constructor for recoverable failure.
Contains only a state token.
Internal
Choice operator (defined with right associativity)
(<|>) :: ParserT st e a -> ParserT st e a -> ParserT st e a infixr 6 Source #
Choose between two parsers. If the first parser fails, try the second one, but if the first one throws an error, propagate the error. This operation can arbitrarily backtrack.
Note: this exported operator has different fixity than the same operator in
Applicative
. Hide this operator if you want to use the
Alternative
version.