summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBasVanDijk <>2017-07-07 22:06:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-07-07 22:06:00 (GMT)
commit8d2e9bdb43874b1ebe329509a2184bc6c75be004 (patch)
tree63c7e4eb1eb7687d1a9814fb1d5cb72f12573faf
parent390ef63ca6f2a22f858c1d691a1714c0aa3966e5 (diff)
version 0.3.5.10.3.5.1
-rw-r--r--changelog3
-rw-r--r--scientific.cabal6
-rw-r--r--src/Data/Scientific.hs24
3 files changed, 19 insertions, 14 deletions
diff --git a/changelog b/changelog
index cc10ff1..39848f4 100644
--- a/changelog
+++ b/changelog
@@ -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)
diff --git a/scientific.cabal b/scientific.cabal
index b40d3c2..a915ec0 100644
--- a/scientific.cabal
+++ b/scientific.cabal
@@ -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 @@ library
, 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 @@ test-suite test-scientific
, 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
diff --git a/src/Data/Scientific.hs b/src/Data/Scientific.hs
index e0563cc..02e338b 100644
--- a/src/Data/Scientific.hs
+++ b/src/Data/Scientific.hs
@@ -105,8 +105,7 @@ import Data.Int (Int8, Int16, Int32, Int64)
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 @@ toIntegral (Scientific c e) = fromInteger c * fromInteger (magnitude e)
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 @@ expts10 = runST $ do
#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