streaming-utils-0.1.3.0: http, attoparsec, pipes and conduit utilities for the streaming libraries

Safe HaskellNone
LanguageHaskell2010

Data.Attoparsec.ByteString.Streaming

Synopsis

Documentation

parse :: Monad m => Parser a -> ByteString m x -> m (Either a Message, ByteString m x) Source

The result of a parse (Either a ([String], String)), with the unconsumed byte stream.

>>> (r,rest1) <- parse (A.scientific <* A.many' A.space) $ "12.3  4.56  78." >> "3"
>>> print r
Left 12.3
>>> (s,rest2) <- parse (A.scientific <* A.many' A.space) rest1
>>> print s
Left 4.56
>>> (t,rest3) <- parse (A.scientific <* A.many' A.space) rest2
>>> print t
Left 78.3
>>> Q.putStrLn rest3

parsed Source

Arguments

:: Monad m 
=> Parser a

Attoparsec parser

-> ByteString m r

Raw input

-> Stream (Of a) m (Either (Message, ByteString m r) r) 

Parse a succession of values from a stream of bytes, ending when the parser fails.or the bytes run out.

>>> S.print $  AS.parsed (A.scientific <* A.many' A.space) $ "12.3  4.56  78." >> "9   18.282"
12.3
4.56
78.9
18.282