Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hpp.Parser
Description
Parsers over streaming input.
Synopsis
- type Parser (m :: Type -> Type) i = ParserT m (Input m [i]) i
- type ParserT (m :: Type -> Type) src i = StateT (Source m src i) m
- evalParse :: Monad m => Parser m i o -> [i] -> m o
- await :: forall (m :: Type -> Type) src i. Monad m => ParserT m src i (Maybe i)
- awaitJust :: forall (m :: Type -> Type) src i. (Monad m, HasError m) => String -> ParserT m src i i
- replace :: forall (m :: Type -> Type) i src. Monad m => i -> ParserT m src i ()
- droppingWhile :: forall (m :: Type -> Type) i src. Monad m => (i -> Bool) -> ParserT m src i ()
- precede :: forall (m :: Type -> Type) i src. Monad m => [i] -> ParserT m src i ()
- takingWhile :: forall (m :: Type -> Type) i src. Monad m => (i -> Bool) -> ParserT m src i [i]
- onElements :: forall (m :: Type -> Type) i r. Monad m => ParserT m (Input m [[i]]) i r -> Parser m [i] r
- onInputSegment :: forall (m :: Type -> Type) src i. Monad m => (src -> src) -> ParserT m (Input m src) i ()
- insertInputSegment :: Monad m => src -> m () -> ParserT m (Input m src) i ()
- onIsomorphism :: forall (m :: Type -> Type) a b src r. Monad m => (a -> b) -> (b -> Maybe a) -> ParserT m ([b], src) b r -> ParserT m src a r
Documentation
type Parser (m :: Type -> Type) i = ParserT m (Input m [i]) i Source #
A Parser
is a bit of state that carries a source of input
consisting of a list of values which are either actions in an
underlying monad or sequences of inputs. Thus we have chunks of
input values with interspersed effects.
type ParserT (m :: Type -> Type) src i = StateT (Source m src i) m Source #
A ParserT
is a bit of state that carries a source of input.
evalParse :: Monad m => Parser m i o -> [i] -> m o Source #
Evaluate a Parser
with a given input stream.
awaitJust :: forall (m :: Type -> Type) src i. (Monad m, HasError m) => String -> ParserT m src i i Source #
await
that throws an error with the given message if no more
input is available. This may be used to locate where in a
processing pipeline input was unexpectedly exhausted.
replace :: forall (m :: Type -> Type) i src. Monad m => i -> ParserT m src i () Source #
Push a value back into a parser's source.
droppingWhile :: forall (m :: Type -> Type) i src. Monad m => (i -> Bool) -> ParserT m src i () Source #
Discard all values until one fails to satisfy a predicate. At
that point, the failing value is replace
d, and the
droppingWhile
stream stops.
precede :: forall (m :: Type -> Type) i src. Monad m => [i] -> ParserT m src i () Source #
Push a stream of values back into a parser's source.
takingWhile :: forall (m :: Type -> Type) i src. Monad m => (i -> Bool) -> ParserT m src i [i] Source #
Echo all values until one fails to satisfy a predicate. At that
point, the failing value is replace
d, and the takingWhile
stream stops.
onElements :: forall (m :: Type -> Type) i r. Monad m => ParserT m (Input m [[i]]) i r -> Parser m [i] r Source #
A parser on lists of things can embed a parser on things. For example, if we have a parser on lists of words, we can embed a parser on individual words.
onInputSegment :: forall (m :: Type -> Type) src i. Monad m => (src -> src) -> ParserT m (Input m src) i () Source #
insertInputSegment :: Monad m => src -> m () -> ParserT m (Input m src) i () Source #