Modulepipes-parse-3.0.9Haskell2010
Pipes.Parse
Element-agnostic parsing utilities for pipes
See Pipes.Parse.Tutorial for an extended tutorial
- 3 types
- 23 values
- Packagepipes-parse-3.0.9
- Exports27
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceParse.hs
Parsing
10 declarationspipes-parse handles end-of-input and pushback by storing a Producer in
a StateT layer.
Connect Parsers to Producers using either runStateT, evalStateT, or execStateT:
runStateT :: Parser a m r -> Producer a m x -> m (r, Producer a m x)
evalStateT :: Parser a m r -> Producer a m x -> m r
execStateT :: Parser a m r -> Producer a m x -> m (Producer a m x)
^^^^^^^^^^^^^^
LeftoversDraw all elements from the underlying Producer
Note that drawAll is not an idiomatic use of pipes-parse, but I provide
it for simple testing purposes. Idiomatic pipes-parse style consumes the
elements immediately as they are generated instead of loading all elements
into memory. For example, you can use foldAll or foldAllM for this
purpose.
Drain all elements from the underlying Producer
Push back an element onto the underlying Producer
Check if the underlying Producer is empty
isEndOfInput = fmap isNothing peekfoldAll Fold all input values
Control.Foldl.purely foldAll :: Monad m => Fold a b -> Parser a m bfoldAllM Fold all input values monadically
Control.Foldl.impurely foldAllM :: Monad m => FoldM a m b -> Parser a m bParsing Lenses
4 declarationsConnect lenses to Producers using (^.) or
view:
(^.) :: Producer a m x
-> Lens' (Producer a m x) (Producer b m y)
-> Producer b m yConnect lenses to Parsers using zoom:
zoom :: Lens' (Producer a m x) (Producer b m y)
-> Parser b m r
-> Parser a m rConnect lenses to each other using (.) (i.e. function composition):
(.) :: Lens' (Producer a m x) (Producer b m y)
-> Lens' (Producer b m y) (Producer c m z)
-> Lens' (Producer a m y) (Producer c m z)Utilities
6 declarationsDeprecated. Use parsed_ instead
Variant of parseForever for parsers which return a Maybe instead of an Either
Re-exports
7 declarationsControl.Monad.Trans.Class re-exports lift.
Control.Monad.Trans.State.Strict re-exports StateT, runStateT, evalStateT, and execStateT.
Lift a computation from the argument monad to the constructed monad.
A state transformer monad parameterized by:
s- The state.m- The inner monad.
The return function leaves the state unchanged, while >>= uses
the final state of the first computation as the initial state of
the second.
Instances23MFunctor, MonadAccum, MonadError, MonadReader, MonadState, MonadWriter, …
MFunctor (StateT s)Defined in mmorph-1.2.1 · Control.Monad.MorphMonadAccum w m => MonadAccum w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.AccumMonadError e m => MonadError e (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Error.ClassMonadReader r m => MonadReader r (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Reader.ClassMonad m => MonadState s (StateT s m)Defined in mtl-2.3.1 · Control.Monad.State.ClassMonadWriter w m => MonadWriter w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Writer.ClassMonadSelect w m => MonadSelect w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Select'Readerizes' the state: the 'ranking' function can see a value of type
s, but not modify it. Effectively, can be thought of as 'extending' the 'ranking' by all values ins, but whichsgets given to any rank calls is predetermined by the 'outer state' (and cannot change).MonadTrans (StateT s)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictFunctor m => Functor (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadFix m => MonadFix (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadFail m => MonadFail (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, Monad m) => Applicative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadPlus m => MonadPlus (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadIO m => MonadIO (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictContravariant m => Contravariant (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadCont m => MonadCont (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCatch m => MonadCatch (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadThrow m => MonadThrow (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchGeneric (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Stricttype Rep (StateT s m a) = D1 ('MetaDataDefined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict"StateT"
"Control.Monad.Trans.State.Strict"
"transformers-0.6.1.1-a11a"
'True) (C1 ('MetaCons"StateT"
'PrefixI 'True) (S1 ('MetaSel ('Just"runStateT"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (s -> m (a, s)))))
Evaluate a state computation with the given initial state and return the final value, discarding the final state.
evalStateT m s = liftM fst (runStateT m s)
Evaluate a state computation with the given initial state and return the final state, discarding the final value.
execStateT m s = liftM snd (runStateT m s)