attoparsec 0.11.2.1 → 0.11.3.0
raw patch · 5 files changed
+52/−32 lines, 5 files
Files
- Data/Attoparsec/ByteString/Char8.hs +14/−6
- Data/Attoparsec/Text.hs +14/−6
- attoparsec.cabal +3/−2
- changelog +0/−18
- changelog.md +21/−0
Data/Attoparsec/ByteString/Char8.hs view
@@ -101,6 +101,7 @@ , Number(..) , number , rational+ , scientific ) where import Control.Applicative (pure, (*>), (<*), (<$>), (<|>))@@ -112,7 +113,8 @@ import Data.ByteString.Internal (c2w, w2c) import Data.Int (Int8, Int16, Int32, Int64) import Data.String (IsString(..))-import Data.Scientific (Scientific, scientific, coefficient, base10Exponent)+import Data.Scientific (Scientific, coefficient, base10Exponent)+import qualified Data.Scientific as Sci (scientific) import Data.Word (Word8, Word16, Word32, Word64, Word) import Prelude hiding (takeWhile) import qualified Data.Attoparsec.ByteString as A@@ -514,6 +516,12 @@ then I (c * 10 ^ e) else D (fromInteger c / 10 ^ negate e) +-- | Parse a scientific number.+--+-- The syntax accepted by this parser is the same as for 'rational'.+scientific :: Parser Scientific+scientific = scientifically id+ {-# INLINE scientifically #-} scientifically :: (Scientific -> a) -> Parser a scientifically h = do@@ -524,13 +532,13 @@ n <- decimal - let f fracDigits = scientific (B8.foldl' step n fracDigits)- (negate $ B8.length fracDigits)+ let f fracDigits = Sci.scientific (B8.foldl' step n fracDigits)+ (negate $ B8.length fracDigits) step a w = a * 10 + fromIntegral (w - 48) s <- let dot = 46 in (I.satisfy (==dot) *> (f <$> I.takeWhile isDigit_w8)) <|>- pure (scientific n 0)+ pure (Sci.scientific n 0) let !signedCoeff | positive = coefficient s | otherwise = negate $ coefficient s@@ -538,5 +546,5 @@ let littleE = 101 bigE = 69 (I.satisfy (\c -> c == littleE || c == bigE) *>- fmap (h . scientific signedCoeff . (base10Exponent s +)) (signed decimal)) <|>- return (h $ scientific signedCoeff (base10Exponent s))+ fmap (h . Sci.scientific signedCoeff . (base10Exponent s +)) (signed decimal)) <|>+ return (h $ Sci.scientific signedCoeff (base10Exponent s))
Data/Attoparsec/Text.hs view
@@ -98,12 +98,14 @@ , Number(..) , number , rational+ , scientific ) where import Control.Applicative (pure, (<$>), (*>), (<*), (<|>)) import Data.Attoparsec.Combinator import Data.Attoparsec.Number (Number(..))-import Data.Scientific (Scientific, scientific, coefficient, base10Exponent)+import Data.Scientific (Scientific, coefficient, base10Exponent)+import qualified Data.Scientific as Sci (scientific) import Data.Attoparsec.Text.Internal (Parser, Result, parse, takeWhile1) import Data.Bits (Bits, (.|.), shiftL) import Data.Char (isAlpha, isDigit, isSpace, ord)@@ -380,6 +382,12 @@ then I (c * 10 ^ e) else D (fromInteger c / 10 ^ negate e) +-- | Parse a scientific number.+--+-- The syntax accepted by this parser is the same as for 'rational'.+scientific :: Parser Scientific+scientific = scientifically id+ {-# INLINE scientifically #-} scientifically :: (Scientific -> a) -> Parser a scientifically h = do@@ -388,19 +396,19 @@ n <- decimal - let f fracDigits = scientific (T.foldl' step n fracDigits)- (negate $ T.length fracDigits)+ let f fracDigits = Sci.scientific (T.foldl' step n fracDigits)+ (negate $ T.length fracDigits) step a c = a * 10 + fromIntegral (ord c - 48) s <- (I.satisfy (=='.') *> (f <$> I.takeWhile isDigit)) <|>- pure (scientific n 0)+ pure (Sci.scientific n 0) let !signedCoeff | positive = coefficient s | otherwise = negate $ coefficient s (I.satisfy (\c -> c == 'e' || c == 'E') *>- fmap (h . scientific signedCoeff . (base10Exponent s +)) (signed decimal)) <|>- return (h $ scientific signedCoeff (base10Exponent s))+ fmap (h . Sci.scientific signedCoeff . (base10Exponent s +)) (signed decimal)) <|>+ return (h $ Sci.scientific signedCoeff (base10Exponent s)) -- | Parse a single digit, as recognised by 'isDigit'. digit :: Parser Char
attoparsec.cabal view
@@ -1,5 +1,5 @@ name: attoparsec-version: 0.11.2.1+version: 0.11.3.0 license: BSD3 license-file: LICENSE category: Text, Parsing@@ -22,7 +22,7 @@ benchmarks/Makefile benchmarks/attoparsec-benchmarks.cabal benchmarks/med.txt.bz2- changelog+ changelog.md examples/*.c examples/*.hs examples/Makefile@@ -34,6 +34,7 @@ Flag developer Description: Whether to build the library in development mode Default: False+ Manual: True library build-depends: array,
− changelog
@@ -1,18 +0,0 @@--*- text -*---0.11.2.0-- * The new Chunk typeclass allows for some code sharing with Ed- Kmett's parsers package: http://hackage.haskell.org/package/parsers-- * New function runScanner generalises scan to return the final state- of the scanner as well as the input consumed.---0.11.1.0-- * New dependency: the scientific package. This allows us to parse- numbers much more efficiently.-- * peekWord8', peekChar': new primitive parsers that allow- single-character lookahead.
+ changelog.md view
@@ -0,0 +1,21 @@+0.11.3.0++* New function scientific is compatible with rational, but parses+ integers more efficiently (https://github.com/bos/aeson/issues/198)++0.11.2.0++* The new Chunk typeclass allows for some code sharing with Ed+ Kmett's parsers package: http://hackage.haskell.org/package/parsers++* New function runScanner generalises scan to return the final state+ of the scanner as well as the input consumed.+++0.11.1.0++* New dependency: the scientific package. This allows us to parse+ numbers much more efficiently.++* peekWord8', peekChar': new primitive parsers that allow+ single-character lookahead.