packages feed

parsec-numbers 0.0.5 → 0.0.6

raw patch · 2 files changed

+29/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.ParserCombinators.Parsec.Number: binDigit :: CharParser st Char
+ Text.ParserCombinators.Parsec.Number: binFloat :: (Integral i, Floating f) => Bool -> CharParser st (Either i f)
+ Text.ParserCombinators.Parsec.Number: binFract :: (Integral i, Fractional f) => Bool -> CharParser st (Either i f)
+ Text.ParserCombinators.Parsec.Number: binFractExp :: Floating f => Integer -> Bool -> CharParser st f
+ Text.ParserCombinators.Parsec.Number: binFraction :: Fractional f => Bool -> CharParser st f

Files

Text/ParserCombinators/Parsec/Number.hs view
@@ -42,8 +42,8 @@ A couple of parsers have been added that take a @Bool@ argument, where @False@ does not require any digit following the decimal dot. The parsers 'fractional3' and 'floating3' allow even to start a number with the decimal-dot. Also parsers 'hexFract' and 'hexFloat' for hexadecimal fractions and-floats have been added.+dot. Also parsers 'hexFract', 'binFract', 'hexFloat' and 'binFloat' for+hexadecimal or binary fractions and floats have been added.  Note that most top-level parsers succeed on a string like \"@1.0e-100@\", but only the floating point parsers consume the whole string. The fractional@@ -102,6 +102,12 @@   n <- hexnum   option (Left n) $ liftM Right $ hexFractExp (toInteger n) b +-- | parse a binary floating point number+binFloat :: (Integral i, Floating f) => Bool -> CharParser st (Either i f)+binFloat b = do+  n <- binary+  option (Left n) $ liftM Right $ binFractExp (toInteger n) b+ -- | parse hexadecimal, octal or decimal integrals or 'floating' natFloat :: (Integral i, Floating f) => CharParser st (Either i f) natFloat = (char '0' >> zeroNumFloat) <|> decimalFloat@@ -121,10 +127,14 @@ fractExponent :: Floating f => Integer -> CharParser st f fractExponent i = fractExp i True --- | parse a hex floating point number given the number before a dot or p+-- | parse a hex floating point number given the number before a dot, p or P hexFractExp :: Floating f => Integer -> Bool -> CharParser st f hexFractExp i b = genFractExp i (hexFraction b) hexExponentFactor +-- | parse a binary floating point number given the number before a dot, p or P+binFractExp :: Floating f => Integer -> Bool -> CharParser st f+binFractExp i b = genFractExp i (binFraction b) hexExponentFactor+ -- | parse a floating point number given the number before a dot, e or E fractExp :: Floating f => Integer -> Bool -> CharParser st f fractExp i b = genFractExp i (fraction b) exponentFactor@@ -191,6 +201,12 @@   n <- hexnum   option (Left n) $ liftM Right $ genFractFract (toInteger n) $ hexFraction b +-- | a binary fractional+binFract :: (Integral i, Fractional f) => Bool -> CharParser st (Either i f)+binFract b = do+  n <- binary+  option (Left n) $ liftM Right $ genFractFract (toInteger n) $ binFraction b+ {- | same as 'fractional' but returns a non-negative integral wrapped by Left if a fractional part is missing -} decimalFract :: (Integral i, Fractional f) => CharParser st (Either i f)@@ -228,6 +244,10 @@ hexFraction :: Fractional f => Bool -> CharParser st f hexFraction b = baseFraction b 16 hexDigit +-- | parse a dot followed by binary digits as fractional part+binFraction :: Fractional f => Bool -> CharParser st f+binFraction b = baseFraction b 2 binDigit+ -- | parse a dot followed by base dependent digits as fractional part baseFraction :: Fractional f => Bool -> Int -> CharParser st Char   -> CharParser st f@@ -261,9 +281,13 @@ decimal :: Integral i => CharParser st i decimal = number 10 digit +-- | parse 0 or 1+binDigit :: CharParser st Char+binDigit = oneOf "01"+ -- | parse a binary number binary :: Integral i => CharParser st i-binary = number 2 $ oneOf "01"+binary = number 2 binDigit  -- | parse non-negative hexadecimal, octal or decimal numbers nat :: Integral i => CharParser st i
parsec-numbers.cabal view
@@ -1,5 +1,5 @@ name:          parsec-numbers-version:       0.0.5+version:       0.0.6 build-type:    Simple cabal-version: >= 1.6 license:       BSD3