scientific 0.3.5.0 → 0.3.5.1
raw patch · 3 files changed
+19/−14 lines, 3 filesdep +primitivedep −vectorPVP ok
version bump matches the API change (PVP)
Dependencies added: primitive
Dependencies removed: vector
API changes (from Hackage documentation)
Files
- changelog +3/−0
- scientific.cabal +3/−3
- src/Data/Scientific.hs +13/−11
changelog view
@@ -1,3 +1,6 @@+0.3.5.1+ * Replace use of Vector from vector with Array from primitive.+ 0.3.5.0 * Export scientificP :: ReadP Scientific (Courtesy of Shlok Datye @shlok)
scientific.cabal view
@@ -1,5 +1,5 @@ name: scientific-version: 0.3.5.0+version: 0.3.5.1 synopsis: Numbers represented using scientific notation description: @Data.Scientific@ provides the number type 'Scientific'. Scientific numbers are@@ -72,7 +72,7 @@ , deepseq >= 1.3 && < 1.5 , text >= 0.8 && < 1.3 , hashable >= 1.1.2 && < 1.3- , vector >= 0.7 && < 0.13+ , primitive >= 0.1 && < 0.7 , containers >= 0.1 && < 0.6 , binary >= 0.4.1 && < 0.9 @@ -104,7 +104,7 @@ , tasty-ant-xml >= 1.0 && < 1.2 , tasty-hunit >= 0.8 && < 0.10 , tasty-smallcheck >= 0.2 && < 0.9- , tasty-quickcheck >= 0.8 && < 0.9+ , tasty-quickcheck >= 0.8 && < 0.10 , smallcheck >= 1.0 && < 1.2 , QuickCheck >= 2.5 && < 2.11 , text >= 0.8 && < 1.3
src/Data/Scientific.hs view
@@ -105,8 +105,7 @@ import qualified Data.Map as M (Map, empty, insert, lookup) import Data.Ratio ((%), numerator, denominator) import Data.Typeable (Typeable)-import qualified Data.Vector as V-import qualified Data.Vector.Mutable as VM+import qualified Data.Primitive.Array as Primitive import Data.Word (Word8, Word16, Word32, Word64) import Math.NumberTheory.Logarithms (integerLog10') import qualified Numeric (floatToDigits)@@ -579,20 +578,20 @@ maxExpt :: Int maxExpt = 324 -expts10 :: V.Vector Integer+expts10 :: Primitive.Array Integer expts10 = runST $ do- mv <- VM.unsafeNew maxExpt- VM.unsafeWrite mv 0 1- VM.unsafeWrite mv 1 10+ ma <- Primitive.newArray maxExpt uninitialised+ Primitive.writeArray ma 0 1+ Primitive.writeArray ma 1 10 let go !ix- | ix == maxExpt = V.unsafeFreeze mv+ | ix == maxExpt = Primitive.unsafeFreezeArray ma | otherwise = do- VM.unsafeWrite mv ix xx- VM.unsafeWrite mv (ix+1) (10*xx)+ Primitive.writeArray ma ix xx+ Primitive.writeArray ma (ix+1) (10*xx) go (ix+2) where xx = x * x- x = V.unsafeIndex expts10 half+ x = Primitive.indexArray expts10 half #if MIN_VERSION_base(4,5,0) !half = ix `unsafeShiftR` 1 #else@@ -600,12 +599,15 @@ #endif go 2 +uninitialised :: error+uninitialised = error "Data.Scientific: uninitialised element"+ -- | @magnitude e == 10 ^ e@ magnitude :: Int -> Integer magnitude e | e < maxExpt = cachedPow10 e | otherwise = cachedPow10 hi * 10 ^ (e - hi) where- cachedPow10 = V.unsafeIndex expts10+ cachedPow10 = Primitive.indexArray expts10 hi = maxExpt - 1