binary-parsers 0.2.2.0 → 0.2.3.0
raw patch · 4 files changed
+39/−8 lines, 4 filesdep ~binaryPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: binary
API changes (from Hackage documentation)
+ Data.Binary.Parser: eitherDecoder :: Decoder r -> Either String r
+ Data.Binary.Parser: infix 0 <?>
+ Data.Binary.Parser: maybeDecoder :: Decoder r -> Maybe r
Files
- ChangeLog.md +8/−2
- Data/Binary/Parser.hs +26/−0
- Data/Binary/Parser/Numeric.hs +4/−5
- binary-parsers.cabal +1/−1
ChangeLog.md view
@@ -1,17 +1,23 @@ # Revision history for binary-parsec +## 0.2.3.0 -- 2016-09-28++* Remove `MultiWayIf` to support older GHC (7.4 and 7.6).+* Add `eitherDecoder` and `maybeDecoder`.++ ## 0.2.2.0 -- 2016-09-21 * Minor optimization to 'takeTill', 'takeWhile' and 'signed'. * Add documents on backtracking. -## 0.2.1.0 -- 2016-09-21+## 0.2.1.0 * Add `parse`,`parseDetail`, `parseDetailLazy`. * Reduce these running functions' overhead so that binary performs well on small getters now. * Add scanner to benchmarks. -## 0.2.0.0 -- 2016-09-21+## 0.2.0.0 * Add `endOfLine` combinator. * Add http request parsing benchmark.
Data/Binary/Parser.hs view
@@ -76,6 +76,9 @@ , parseDetail , parseDetailLazy , parse+ -- * Decoder conversion+ , maybeDecoder+ , eitherDecoder -- * Combinators , (<?>) , endOfInput@@ -213,6 +216,29 @@ I.BytesRead n k -> I.BytesRead n (completeLoop . k) I.Fail _ _ -> r I.Done _ _ -> r++--------------------------------------------------------------------------------++-- | Convert a 'Decoder' value to a 'Maybe' value. A 'Partial' result+-- is treated as failure.+--+-- /Since: 0.2.3.0/+--+maybeDecoder :: Decoder r -> Maybe r+maybeDecoder (Done _ _ r) = Just r+maybeDecoder _ = Nothing+{-# INLINE maybeDecoder #-}++-- | Convert a 'Decoder' value to an 'Either' value. A 'Partial'+-- result is treated as failure.+--+-- /Since: 0.2.3.0/+--+eitherDecoder :: Decoder r -> Either String r+eitherDecoder (Done _ _ r) = Right r+eitherDecoder (Fail _ _ msg) = Left msg+eitherDecoder _ = Left "Decoder: incomplete input"+{-# INLINE eitherDecoder #-} --------------------------------------------------------------------------------
Data/Binary/Parser/Numeric.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE MultiWayIf #-} -- | -- Module : Data.Binary.Parser.Numeric -- Copyright : Bryan O'Sullivan 2007-2015, Winterland 2016@@ -78,9 +77,9 @@ signed :: Num a => Get a -> Get a signed p = do w <- W.peek- if | w == MINUS -> W.skipN 1 >> negate <$> p- | w == PLUS -> W.skipN 1 >> p- | otherwise -> p+ if w == MINUS+ then W.skipN 1 >> negate <$> p+ else if w == PLUS then W.skipN 1 >> p else p {-# SPECIALISE signed :: Get Int -> Get Int #-} {-# SPECIALISE signed :: Get Int8 -> Get Int8 #-} {-# SPECIALISE signed :: Get Int16 -> Get Int16 #-}@@ -153,7 +152,7 @@ intPart <- decimal sci <- (do fracDigits <- W.word8 DOT >> W.takeWhile1 W.isDigit let e' = B.length fracDigits- intPart' = intPart * (10 ^ B.length fracDigits)+ intPart' = intPart * (10 ^ e') fracPart = LexInt.readDecimal_ fracDigits parseE (intPart' + fracPart) e' ) <|> (parseE intPart 0)
binary-parsers.cabal view
@@ -1,5 +1,5 @@ name: binary-parsers-version: 0.2.2.0+version: 0.2.3.0 synopsis: Extends binary with parsec/attoparsec style parsing combinators. description: Extends binary with parsec/attoparsec style parsing combinators. license: BSD3