hpp-0.4.0: A Haskell pre-processor

Safe HaskellNone
LanguageHaskell2010

Hpp.Parser

Description

Parsers over streaming input.

Synopsis

Documentation

type Parser m i = ParserT m (RopeM m [i]) i #

type ParserT m src i = StateT (Headspring m src i, src) m #

A Parser is a bit of state carrying a source of input.

parse :: Monad m => Parser m i o -> [i] -> m (o, RopeM m [i]) #

Run a Parser with a given input stream.

evalParse :: Monad m => Parser m i o -> [i] -> m o #

await :: Monad m => ParserT m src i (Maybe i) #

awaitJust :: (Monad m, HasError m) => String -> ParserT m src i i #

awaitP 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 :: Monad m => i -> ParserT m src i () #

Push a value back into a parser's source.

droppingWhile :: Monad m => (i -> Bool) -> ParserT m src i () #

Discard all values until one fails to satisfy a predicate. At that point, the failing value is replaced, and the droppingWhile stream stops.

precede :: Monad m => [i] -> ParserT m src i () #

Push a stream of values back into a parser's source.

takingWhile :: Monad m => (i -> Bool) -> ParserT m src i [i] #

Echo all values until one fails to satisfy a predicate. At that point, the failing value is replaced, and the takingWhile stream stops.

onChunks :: Monad m => ParserT m (RopeM m [i]) [i] r -> Parser m i r #

onElements :: Monad m => ParserT m (RopeM m [[i]]) i r -> Parser m [i] r #

onInputSegment :: Monad m => (src -> src) -> ParserT m (RopeM m src) i () #

insertInputSegment :: Monad m => src -> m () -> ParserT m (RopeM m src) i () #

onIsomorphism :: forall m a b src r. Monad m => (a -> b) -> (b -> Maybe a) -> ParserT m ([b], src) b r -> ParserT m src a r #

runParser :: Monad m => Parser m i o -> RopeM m [i] -> m (o, RopeM m [i]) #