Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Message = ([String], String)
- parse :: Monad m => Parser a -> ByteString m x -> m (Either a Message, ByteString m x)
- parsed :: Monad m => Parser a -> ByteString m r -> Stream (Of a) m (Either (Message, ByteString m r) r)
- module Data.Attoparsec.ByteString
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
:: 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
module Data.Attoparsec.ByteString