packages feed

parsec3-numbers 0.0.5 → 0.0.6

raw patch · 2 files changed

+32/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Parsec.Number: binDigit :: Stream s m Char => ParsecT s u m Char
+ Text.Parsec.Number: binFloat :: (Integral i, Floating f, Stream s m Char) => Bool -> ParsecT s u m (Either i f)
+ Text.Parsec.Number: binFract :: (Integral i, Fractional f, Stream s m Char) => Bool -> ParsecT s u m (Either i f)
+ Text.Parsec.Number: binFractExp :: (Floating f, Stream s m Char) => Integer -> Bool -> ParsecT s u m f
+ Text.Parsec.Number: binFraction :: (Fractional f, Stream s m Char) => Bool -> ParsecT s u m f

Files

Text/Parsec/Number.hs view
@@ -44,8 +44,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@@ -107,6 +107,13 @@   n <- hexnum   option (Left n) $ liftM Right $ hexFractExp (toInteger n) b +-- | parse a binary floating point number+binFloat :: (Integral i, Floating f, Stream s m Char)+  => Bool -> ParsecT s u m (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, Stream s m Char)   => ParsecT s u m (Either i f)@@ -128,11 +135,16 @@ fractExponent :: (Floating f, Stream s m Char) => Integer -> ParsecT s u m 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, Stream s m Char) => Integer -> Bool   -> ParsecT s u m 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, Stream s m Char) => Integer -> Bool+  -> ParsecT s u m 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, Stream s m Char) => Integer -> Bool   -> ParsecT s u m f@@ -203,6 +215,13 @@   n <- hexnum   option (Left n) $ liftM Right $ genFractFract (toInteger n) $ hexFraction b +-- | a binary fractional+binFract :: (Integral i, Fractional f, Stream s m Char)+  => Bool -> ParsecT s u m (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, Stream s m Char)@@ -245,6 +264,10 @@ hexFraction :: (Fractional f, Stream s m Char) => Bool -> ParsecT s u m f hexFraction b = baseFraction b 16 hexDigit +-- | parse a dot followed by binary digits as fractional part+binFraction :: (Fractional f, Stream s m Char) => Bool -> ParsecT s u m f+binFraction b = baseFraction b 2 binDigit+ -- | parse a dot followed by base dependent digits as fractional part baseFraction :: (Fractional f, Stream s m Char) => Bool -> Int   -> ParsecT s u m Char -> ParsecT s u m f@@ -278,9 +301,13 @@ decimal :: (Integral i, Stream s m Char) => ParsecT s u m i decimal = number 10 digit +-- | parse 0 or 1+binDigit :: Stream s m Char => ParsecT s u m Char+binDigit = oneOf "01"+ -- | parse a binary number binary :: (Integral i, Stream s m Char) => ParsecT s u m i-binary = number 2 $ oneOf "01"+binary = number 2 binDigit  -- | parse non-negative hexadecimal, octal or decimal numbers nat :: (Integral i, Stream s m Char) => ParsecT s u m i
parsec3-numbers.cabal view
@@ -1,5 +1,5 @@ name:          parsec3-numbers-version:       0.0.5+version:       0.0.6 build-type:    Simple cabal-version: >= 1.6 license:       BSD3