Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Minimal parser definition.
Synopsis
- newtype ParserT (st :: ZeroBitType) r e a = ParserT {
- runParserT# :: ForeignPtrContents -> r -> Addr# -> Addr# -> Int# -> 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# -> Int# -> 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#, Int# #) | (# #) | (# e #) #)
- (<|>) :: ParserT st r e a -> ParserT st r e a -> ParserT st r e a
Parser
newtype ParserT (st :: ZeroBitType) r e a Source #
ParserT st r e a
is a parser with a state token type st
, a reader
environment r
, 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 (ParserT IOMode r e) Source # | |
Alternative (ParserT st r e) Source # | |
Applicative (ParserT st r e) Source # | |
Defined in FlatParse.Stateful.Parser pure :: a -> ParserT st r e a # (<*>) :: ParserT st r e (a -> b) -> ParserT st r e a -> ParserT st r e b # liftA2 :: (a -> b -> c) -> ParserT st r e a -> ParserT st r e b -> ParserT st r e c # (*>) :: ParserT st r e a -> ParserT st r e b -> ParserT st r e b # (<*) :: ParserT st r e a -> ParserT st r e b -> ParserT st r e a # | |
Functor (ParserT st r e) Source # | |
Monad (ParserT st r e) Source # | |
MonadPlus (ParserT st r e) Source # | |
Result
type Res# (st :: ZeroBitType) e a = (# st, ResI# e a #) Source #
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 r e a -> ParserT st r e a -> ParserT st r 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.