Modulepipes-parse-3.0.9Haskell2010
Pipes.Parse
Element-agnostic parsing utilities for pipes
See Pipes.Parse.Tutorial for an extended tutorial
Contents
Synopsis
- type Parser
- value draw
- value skip
- value drawAll
- value skipAll
- value unDraw
- value peek
- value isEndOfInput
- value foldAll
- value foldAllM
- value span
- value splitAt
- value groupBy
- value group
- value toParser
- value toParser_
- value parsed
- value parsed_
- value parseForever
- value parseForever_
- method lift
- value evalStateT
- value execStateT
- newtype StateT
- value next
- value yield
- type Producer
- Packagepipes-parse-3.0.9
- Exports27
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceParse.hs
Parsing
pipes-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
Connect 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
Deprecated. Use parsed_ instead
Variant of parseForever for parsers which return a Maybe instead of an Either
Re-exports
Control.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.
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)
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.2 · Control.Monad.MorphMonadAccum w m => MonadAccum w (StateT s m)Defined in mtl-2.3.2 · Control.Monad.AccumMonadError e m => MonadError e (StateT s m)Defined in mtl-2.3.2 · Control.Monad.Error.ClassMonadReader r m => MonadReader r (StateT s m)Defined in mtl-2.3.2 · Control.Monad.Reader.ClassMonad m => MonadState s (StateT s m)Defined in mtl-2.3.2 · Control.Monad.State.ClassMonadWriter w m => MonadWriter w (StateT s m)Defined in mtl-2.3.2 · Control.Monad.Writer.ClassMonadSelect w m => MonadSelect w (StateT s m)Defined in mtl-2.3.2 · 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.3.0 · Control.Monad.Trans.State.StrictMonad m => Monad (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictFunctor m => Functor (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictMonadFix m => MonadFix (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictMonadFail m => MonadFail (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Strict(Functor m, Monad m) => Applicative (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Strict(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictMonadPlus m => MonadPlus (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictMonadIO m => MonadIO (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictContravariant m => Contravariant (StateT s m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.StrictMonadCont m => MonadCont (StateT s m)Defined in mtl-2.3.2 · Control.Monad.Cont.ClassMonadCatch m => MonadCatch (StateT s m)Defined in exceptions-0.10.12 · Control.Monad.CatchMonadMask m => MonadMask (StateT s m)Defined in exceptions-0.10.12 · Control.Monad.CatchMonadThrow m => MonadThrow (StateT s m)Defined in exceptions-0.10.12 · Control.Monad.CatchGeneric (StateT s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Stricttype Rep (StateT s m a) = D1 ('MetaDataDefined in transformers-0.6.3.0 · Control.Monad.Trans.State.Strict"StateT"
"Control.Monad.Trans.State.Strict"
"transformers-0.6.3.0-34b4"
'True) (C1 ('MetaCons"StateT"
'PrefixI 'True) (S1 ('MetaSel ('Just"runStateT"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (s -> m (a, s)))))