scientific-notation 0.1.0.1 → 0.1.1.0
raw patch · 3 files changed
+25/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Number.Scientific: withExposed :: (Int -> Int -> a) -> (Integer -> Integer -> a) -> Scientific -> a
Files
- CHANGELOG.md +9/−0
- scientific-notation.cabal +2/−1
- src/Data/Number/Scientific.hs +14/−0
CHANGELOG.md view
@@ -1,5 +1,14 @@ # Revision history for scientific-notation +## 0.1.1.0 -- 2019-11-06++* Add `withExposed`.+* Start building with `-O2`.++## 0.1.0.1 -- 2019-09-30++* Make compatible with `bytesmith-0.3`.+ ## 0.1.0.0 -- 2019-09-24 * First version. Released on an unsuspecting world.
scientific-notation.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: scientific-notation-version: 0.1.0.1+version: 0.1.1.0 synopsis: Scientific notation intended for tokenization description: This library provides a type used to represent a number in@@ -51,6 +51,7 @@ , base >=4.12 && <5 , bytesmith >=0.3 && <0.4 hs-source-dirs: src+ ghc-options: -O2 -Wall default-language: Haskell2010 test-suite test
src/Data/Number/Scientific.hs view
@@ -21,6 +21,7 @@ , toInt , toInt32 , toInt64+ , withExposed -- * Decode , parserSignedUtf8Bytes , parserTrailingUtf8Bytes@@ -176,6 +177,19 @@ toInt64 (Scientific (I# coeff) (I# e) largeNum) = case toInt# coeff e largeNum of (# (# #) | #) -> Nothing (# | i #) -> Just (I64# i)++-- | Expose the non-normalized exponent and coefficient.+withExposed ::+ (Int -> Int -> a)+ -- ^ Called when coefficient and exponent are small+ -> (Integer -> Integer -> a)+ -- ^ Called when coefficient and exponent are large+ -> Scientific+ -> a+withExposed f g (Scientific coeff theExp big) = if theExp /= minBound+ then f coeff theExp+ else case big of+ LargeScientific coeff' theExp' -> g coeff' theExp' toSmallHelper :: (Int -> Int -> (# (# #) | Word# #) ) -- small