Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A context-free memoizing parser that handles all alternatives in parallel and carries a monadic computation with each parsing result.
Synopsis
- newtype ParserT m g s r = Parser {
- applyParser :: [(s, g (ResultListT m g s))] -> ResultListT m g s r
- data ResultListT m g s r = ResultList ![ResultsOfLengthT m g s r] (ParseFailure Pos s)
- newtype ResultsOfLengthT m g s r = ResultsOfLengthT {
- getResultsOfLength :: ResultsOfLength m g s (m r)
- data ResultsOfLength m g s a = ROL !Int ![(s, g (ResultListT m g s))] !(NonEmpty a)
- tbind :: Monad m => ParserT m g s a -> (a -> m b) -> ParserT m g s b
- lift :: Ord s => m a -> ParserT m g s a
- tmap :: (m a -> m b) -> ParserT m g s a -> ParserT m g s b
- longest :: ParserT Identity g s a -> Parser g [(s, g (ResultListT Identity g s))] a
- peg :: (Applicative m, Ord s) => Parser g [(s, g (ResultListT m g s))] a -> ParserT m g s a
- terminalPEG :: (Applicative m, Monoid s, Ord s) => Parser g s a -> ParserT m g s a
Documentation
newtype ParserT m g s r Source #
Parser for a context-free grammar with packrat-like sharing that carries a monadic computation as part of the parse result.
Parser | |
|
Instances
data ResultListT m g s r Source #
ResultList ![ResultsOfLengthT m g s r] (ParseFailure Pos s) |
Instances
newtype ResultsOfLengthT m g s r Source #
ResultsOfLengthT | |
|
Instances
(Applicative m, Ord s) => Applicative (ResultsOfLengthT m g s) Source # | |
Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer pure :: a -> ResultsOfLengthT m g s a # (<*>) :: ResultsOfLengthT m g s (a -> b) -> ResultsOfLengthT m g s a -> ResultsOfLengthT m g s b # liftA2 :: (a -> b -> c) -> ResultsOfLengthT m g s a -> ResultsOfLengthT m g s b -> ResultsOfLengthT m g s c # (*>) :: ResultsOfLengthT m g s a -> ResultsOfLengthT m g s b -> ResultsOfLengthT m g s b # (<*) :: ResultsOfLengthT m g s a -> ResultsOfLengthT m g s b -> ResultsOfLengthT m g s a # | |
Functor m => Functor (ResultsOfLengthT m g s) Source # | |
Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer fmap :: (a -> b) -> ResultsOfLengthT m g s a -> ResultsOfLengthT m g s b # (<$) :: a -> ResultsOfLengthT m g s b -> ResultsOfLengthT m g s a # |
data ResultsOfLength m g s a Source #
ROL !Int ![(s, g (ResultListT m g s))] !(NonEmpty a) |
Instances
(Applicative m, Ord s) => Applicative (ResultsOfLength m g s) Source # | |
Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer pure :: a -> ResultsOfLength m g s a # (<*>) :: ResultsOfLength m g s (a -> b) -> ResultsOfLength m g s a -> ResultsOfLength m g s b # liftA2 :: (a -> b -> c) -> ResultsOfLength m g s a -> ResultsOfLength m g s b -> ResultsOfLength m g s c # (*>) :: ResultsOfLength m g s a -> ResultsOfLength m g s b -> ResultsOfLength m g s b # (<*) :: ResultsOfLength m g s a -> ResultsOfLength m g s b -> ResultsOfLength m g s a # | |
Functor (ResultsOfLength m g s) Source # | |
Defined in Text.Grampa.ContextFree.SortedMemoizing.Transformer fmap :: (a -> b) -> ResultsOfLength m g s a -> ResultsOfLength m g s b # (<$) :: a -> ResultsOfLength m g s b -> ResultsOfLength m g s a # |
tbind :: Monad m => ParserT m g s a -> (a -> m b) -> ParserT m g s b Source #
Transform the computation carried by the parser using the monadic bind (>>=
).
tmap :: (m a -> m b) -> ParserT m g s a -> ParserT m g s b Source #
Transform the computation carried by the parser.
longest :: ParserT Identity g s a -> Parser g [(s, g (ResultListT Identity g s))] a Source #
Turns a context-free parser into a backtracking PEG parser that consumes the longest possible prefix of the list
of input tails, opposite of peg
peg :: (Applicative m, Ord s) => Parser g [(s, g (ResultListT m g s))] a -> ParserT m g s a Source #
Turns a backtracking PEG parser of the list of input tails into a context-free parser, opposite of longest
terminalPEG :: (Applicative m, Monoid s, Ord s) => Parser g s a -> ParserT m g s a Source #
Turns a backtracking PEG parser into a context-free parser