-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parsing infrastructure for the pipes ecosystem -- @package pipes-parse @version 3.0.3 -- | Element-agnostic parsing utilities for pipes -- -- See Pipes.Parse.Tutorial for an extended tutorial module Pipes.Parse -- | A Parser is an action that reads from and writes to a stored -- Producer type Parser a m r = forall x. StateT (Producer a m x) m r -- | Draw one element from the underlying Producer, returning -- Nothing if the Producer is empty draw :: Monad m => Parser a m (Maybe a) -- | Skip one element from the underlying Producer, returning -- True if successful or False if the Producer is -- empty -- --
--   skip = fmap isJust draw
--   
skip :: Monad m => Parser a m Bool -- | Draw 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. drawAll :: Monad m => Parser a m [a] -- | Drain all elements from the underlying Producer skipAll :: Monad m => Parser a m () -- | Push back an element onto the underlying Producer unDraw :: Monad m => a -> Parser a m () -- | peek checks the first element of the stream, but uses -- unDraw to push the element back so that it is available for the -- next draw command. -- --
--   peek = do
--       x <- draw
--       case x of
--           Nothing -> return ()
--           Just a  -> unDraw a
--       return x
--   
peek :: Monad m => Parser a m (Maybe a) -- | Check if the underlying Producer is empty -- --
--   isEndOfInput = fmap isNothing peek
--   
isEndOfInput :: Monad m => Parser a m Bool -- | Fold all input values -- --
--   Control.Foldl.purely foldAll :: Monad m => Fold a b -> Parser a m b
--   
foldAll :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Parser a m b -- | Fold all input values monadically -- --
--   Control.Foldl.impurely foldAllM :: Monad m => FoldM a m b -> Parser a m b
--   
foldAllM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> Parser a m b -- | span is an improper lens that splits the Producer into -- two Producers, where the outer Producer is the longest -- consecutive group of elements that satisfy the predicate span :: Monad m => (a -> Bool) -> Lens' (Producer a m x) (Producer a m (Producer a m x)) -- | splitAt is an improper lens that splits a Producer into -- two Producers after a fixed number of elements splitAt :: Monad m => Int -> Lens' (Producer a m x) (Producer a m (Producer a m x)) -- | groupBy splits a Producer into two Producers -- after the first group of elements that are equal according to the -- equality predicate groupBy :: Monad m => (a -> a -> Bool) -> Lens' (Producer a m x) (Producer a m (Producer a m x)) -- | Like groupBy, where the equality predicate is (==) group :: (Monad m, Eq a) => Lens' (Producer a m x) (Producer a m (Producer a m x)) -- | Convert a Consumer to a Parser -- -- Nothing signifies end of input toParser :: Monad m => Consumer (Maybe a) m r -> Parser a m r -- | Convert a never-ending Consumer to a Parser toParser_ :: Monad m => Consumer a m X -> Parser a m () -- | Convert a Parser to a Pipe by running it repeatedly on -- the input parseForever :: Monad m => (forall n. Monad n => Parser a n (Either r b)) -> Pipe a b m r -- | Variant of parseForever for parsers which return a Maybe -- instead of an Either parseForever_ :: Monad m => (forall n. Monad n => Parser a n (Maybe b)) -> Pipe a b m () -- | pipes-parse builds upon pipes to add several missing -- features necessary to implement Parsers: -- -- module Pipes.Parse.Tutorial