fastparser 0.3.0.1 → 0.3.1
raw patch · 3 files changed
+17/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ ByteString.Parser.Fast: satisfy :: (Char -> Bool) -> Parser Char
Files
- CHANGELOG.md +4/−0
- fastparser.cabal +1/−1
- src/ByteString/Parser/Fast.hs +12/−2
CHANGELOG.md view
@@ -1,3 +1,7 @@+v0.3.1++ * Added the satisfy function+ v0.3.0.1 * Parser is now wrapped in Codensity, as the performance impact is minimal
fastparser.cabal view
@@ -1,5 +1,5 @@ name: fastparser-version: 0.3.0.1+version: 0.3.1 synopsis: A fast, but bare bones, bytestring parser combinators library. description: Please see README.md homepage: https://github.com/bartavelle/fastparser#readme
src/ByteString/Parser/Fast.hs view
@@ -54,7 +54,7 @@ -- * Parsing numerical values decimal, num, hnum, onum, frac, scientific, -- * Parsing characters- anyChar, char, string, quotedString,+ satisfy, anyChar, char, string, quotedString, -- * Various combinators takeN, remaining, charTakeWhile, charTakeWhile1, ByteString.Parser.Fast.takeWhile, takeWhile1, skipWhile, -- * Parsing time-related values@@ -218,7 +218,7 @@ -- | Parses any positives octal 'Num'. onum :: Num n => Parser n-onum = BS.foldl' (\acc n -> acc * 8 + fromIntegral (n - 0x30)) 0 <$> takeWhile1 isHexa+onum = BS.foldl' (\acc n -> acc * 8 + fromIntegral (n - 0x30)) 0 <$> takeWhile1 isDigit {-# INLINABLE onum #-} -- | Parses 'Fractional' numbers.@@ -242,6 +242,16 @@ char :: Char -> Parser () char c = lift $ Parser $ \input failure success -> if BS.null input then failure ueof else if BS8.head input == c then success (BS.tail input) () else failure (parseError (BS8.take 1 input) (BS8.singleton c)) {-# INLINE char #-}++-- | Parses a character satisfying a predicate+satisfy :: (Char -> Bool) -> Parser Char+satisfy p = lift $ Parser $ \input failure success ->+ if BS.null input+ then failure ueof+ else let c = BS8.head input+ in if p c+ then success (BS.tail input) c+ else failure (parseError (BS8.take 1 input) (BS8.singleton c)) -- | Parses the supplied string. string :: BS.ByteString -> Parser ()