bsparse 0.0.2 → 0.0.3
raw patch · 2 files changed
+26/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.ByteString.Parse: skipAll :: Parser ()
+ Data.ByteString.Parse: takeAll :: Parser ByteString
Files
- Data/ByteString/Parse.hs +25/−0
- bsparse.cabal +1/−1
Data/ByteString/Parse.hs view
@@ -27,8 +27,10 @@ , bytes , take , takeWhile+ , takeAll , skip , skipWhile+ , skipAll ) where import Control.Applicative@@ -102,6 +104,18 @@ then err buf "EOL: need more data" else ok (B.append buf nextChunk) () +getAll :: Parser ()+getAll = Parser $ \buf err ok -> ParseMore $ \nextChunk ->+ if B.null nextChunk+ then ok buf ()+ else runParser getAll (B.append buf nextChunk) err ok++flushAll :: Parser ()+flushAll = Parser $ \buf err ok -> ParseMore $ \nextChunk ->+ if B.null nextChunk+ then ok buf ()+ else runParser getAll B.empty err ok+ ------------------------------------------------------------ -- | Get the next byte from the parser@@ -161,6 +175,13 @@ (_, "") -> runParser (getMore >> takeWhile predicate) buf err ok (b1, b2) -> ok b2 b1 +-- | Take the remaining bytes from the current position in the stream+takeAll :: Parser ByteString+takeAll = Parser $ \buf err ok ->+ runParser (getAll >> returnBuffer) buf err ok+ where+ returnBuffer = Parser $ \buf _ ok -> ok B.empty buf+ -- | Skip @n bytes from the current position in the stream skip :: Int -> Parser () skip n = Parser $ \buf err ok ->@@ -174,3 +195,7 @@ case B.span p buf of (_, "") -> runParser (getMore >> skipWhile p) B.empty err ok (_, b2) -> ok b2 ()++-- | Skip all the remaining bytes from the current position in the stream+skipAll :: Parser ()+skipAll = Parser $ \buf err ok -> runParser flushAll buf err ok
bsparse.cabal view
@@ -1,5 +1,5 @@ Name: bsparse-Version: 0.0.2+Version: 0.0.3 Synopsis: A simple unassuming parser for bytestring Description: Really trivial parser to get and drop bytes from a bytestring License: BSD3