packages feed

double-conversion 2.0.4.0 → 2.0.4.1

raw patch · 7 files changed

+56/−36 lines, 7 filesdep ~basedep ~bytestringdep ~text

Dependency ranges changed: base, bytestring, text

Files

Data/Double/Conversion/Internal/ByteStringBuilder.hs view
@@ -21,7 +21,7 @@  import Control.Monad (when) -import Data.ByteString.Builder.Prim.Internal (BoundedPrim, boundedPrim)+import Data.ByteString.Builder.Prim.Internal (BoundedPrim, boudedPrim)  import Data.Double.Conversion.Internal.FFI (ForeignFloating) import Data.Word (Word8)@@ -32,7 +32,7 @@ {-# SPECIALIZE convert :: String -> CInt -> (CDouble -> Ptr Word8 -> IO CInt) -> BoundedPrim Double #-} {-# SPECIALIZE convert :: String -> CInt -> (CFloat -> Ptr Word8 -> IO CInt) -> BoundedPrim Float #-} {-# INLINABLE convert #-}-convert func len act = boundedPrim (fromIntegral len) $ \val ptr -> do+convert func len act = boudedPrim (fromIntegral len) $ \val ptr -> do   size <- act (realToFrac val) ptr   when (size == -1) .     fail $ "Data.Double.Conversion.ByteString." ++ func ++
Data/Double/Conversion/Internal/FFI.hs view
@@ -55,27 +55,15 @@ foreign import ccall unsafe "hs-double-conversion.h _hs_ToShortestLength"     c_ToShortestLength :: CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToShortest"-    c_Text_ToShortest :: CDouble -> MutableByteArray# s -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToShortest"     c_ToShortest :: CDouble -> Ptr Word8 -> IO CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToShortestFloat"-    c_Text_ToShortestFloat :: CFloat -> MutableByteArray# s -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToShortestFloat"     c_ToShortestFloat :: CFloat -> Ptr Word8 -> IO CInt  foreign import ccall unsafe "hs-double-conversion.h _hs_ToFixedLength"     c_ToFixedLength :: CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToFixed"-    c_Text_ToFixed :: CDouble -> MutableByteArray# s -> CInt -> IO CInt--foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToFixedFloat"-    c_Text_ToFixedFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToFixed"     c_ToFixed :: CDouble -> Ptr Word8 -> CInt -> IO CInt @@ -85,29 +73,53 @@ foreign import ccall unsafe "hs-double-conversion.h _hs_ToExponentialLength"     c_ToExponentialLength :: CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToExponential"-    c_Text_ToExponential :: CDouble -> MutableByteArray# s -> CInt -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToExponential"     c_ToExponential :: CDouble -> Ptr Word8 -> CInt -> IO CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToExponentialFloat"-    c_Text_ToExponentialFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToExponentialFloat"     c_ToExponentialFloat :: CFloat -> Ptr Word8 -> CInt -> IO CInt  foreign import ccall unsafe "hs-double-conversion.h _hs_ToPrecisionLength"     c_ToPrecisionLength :: CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToPrecision"-    c_Text_ToPrecision :: CDouble -> MutableByteArray# s -> CInt -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToPrecision"     c_ToPrecision :: CDouble -> Ptr Word8 -> CInt -> IO CInt -foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToPrecisionFloat"-    c_Text_ToPrecisionFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt- foreign import ccall unsafe "hs-double-conversion.h _hs_ToPrecisionFloat"     c_ToPrecisionFloat :: CFloat -> Ptr Word8 -> CInt -> IO CInt++#if MIN_VERSION_text(2,0,0)+foreign import ccall unsafe "hs-double-conversion.h _hs_ToShortest"+    c_Text_ToShortest :: CDouble -> MutableByteArray# s -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToShortestFloat"+    c_Text_ToShortestFloat :: CFloat -> MutableByteArray# s -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToFixed"+    c_Text_ToFixed :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToFixedFloat"+    c_Text_ToFixedFloat :: CFloat -> MutableByteArray# s-> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToExponential"+    c_Text_ToExponential :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToExponentialFloat"+    c_Text_ToExponentialFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToPrecision"+    c_Text_ToPrecision :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_ToPrecisionFloat"+    c_Text_ToPrecisionFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt+#else+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToShortest"+    c_Text_ToShortest :: CDouble -> MutableByteArray# s -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToShortestFloat"+    c_Text_ToShortestFloat :: CFloat -> MutableByteArray# s -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToFixed"+    c_Text_ToFixed :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToFixedFloat"+    c_Text_ToFixedFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToExponential"+    c_Text_ToExponential :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToExponentialFloat"+    c_Text_ToExponentialFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToPrecision"+    c_Text_ToPrecision :: CDouble -> MutableByteArray# s -> CInt -> IO CInt+foreign import ccall unsafe "hs-double-conversion.h _hs_Text_ToPrecisionFloat"+    c_Text_ToPrecisionFloat :: CFloat -> MutableByteArray# s -> CInt -> IO CInt+#endif
Data/Double/Conversion/Internal/Text.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, MagicHash, Rank2Types, TypeFamilies #-}+{-# LANGUAGE CPP, MagicHash, Rank2Types, TypeFamilies, BangPatterns #-}  -- | -- Module      : Data.Double.Conversion.Text@@ -45,7 +45,12 @@     go :: (forall s. ST s Text)     go = do       buf <- A.new (fromIntegral len)-      size <- unsafeIOToST $ act (realToFrac val) (A.maBA buf)+#if MIN_VERSION_text(2,0,0)+      let !(A.MutableByteArray ma) = buf+#else+      let ma = A.maBA buf+#endif+      size <- unsafeIOToST $ act (realToFrac val) ma       when (size == -1) .         fail $ "Data.Double.Conversion.Text." ++ func ++                ": conversion failed (invalid precision requested)"
Data/Double/Conversion/Internal/TextBuilder.hs view
@@ -17,7 +17,6 @@       convert     ) where - import Control.Monad (when) #if MIN_VERSION_base(4,4,0) import Control.Monad.ST.Unsafe (unsafeIOToST)@@ -37,7 +36,11 @@ {-# SPECIALIZE convert :: String -> CInt -> (forall s. CDouble -> MutableByteArray# s -> IO CInt) -> Double -> Builder #-} {-# SPECIALIZE convert :: String -> CInt -> (forall s. CFloat -> MutableByteArray# s -> IO CInt) -> Float -> Builder #-} {-# INLINABLE convert #-}+#if MIN_VERSION_text(2,0,0)+convert func len act val = writeN (fromIntegral len) $ \(A.MutableByteArray maBa) _ -> do+#else convert func len act val = writeN (fromIntegral len) $ \(A.MArray maBa) _ -> do+#endif     size <- unsafeIOToST $ act (realToFrac val) maBa     when (size == -1) .         fail $ "Data.Double.Conversion.Text." ++ func ++
double-conversion.cabal view
@@ -1,5 +1,5 @@ name:           double-conversion-version:        2.0.4.0+version:        2.0.4.1 license:        BSD3 license-file:   LICENSE homepage:       https://github.com/Haskell-mouse/double-conversion@@ -108,7 +108,7 @@     base == 4.*,     bytestring,     ghc-prim,-    text >= 0.11.0.8 && < 2.0+    text >= 0.11.0.8    if flag(developer)     ghc-options: -Werror 
tests/Properties.hs view
@@ -1,7 +1,7 @@ import Test.Framework (Test, defaultMain, testGroup) import Test.Framework.Providers.QuickCheck2 (testProperty) import qualified Data.ByteString.Char8 as B-import qualified Data.FP.Conversion.Convertable as B+import qualified Data.Double.Conversion.Convertable as C import qualified Data.Text as T import qualified Regressions @@ -14,8 +14,8 @@  tests :: Test tests = testGroup "Properties" [-    testProperty "b_shortest" $ shortest (B.unpack . toShortest)-  , testProperty "t_shortest" $ shortest (T.unpack . toShortest)+    testProperty "b_shortest" $ shortest (B.unpack . C.toShortest)+  , testProperty "t_shortest" $ shortest (T.unpack . C.toShortest)   ]  main :: IO ()
tests/Regressions.hs view
@@ -3,7 +3,7 @@       tests     ) where -import Data.FP.Conversion.Convertable+import Data.Double.Conversion.Convertable import Test.HUnit (Assertion, assertEqual) import Data.Text (unpack) import Numeric (showFFloat)@@ -12,7 +12,7 @@  toShortest_overflow :: Assertion toShortest_overflow = do-  let val = -2.9658956854023756e-5+  let val = -2.9658956854023756e-5 :: Double   assertEqual "rendering a long number doesn't crash"               (showFFloat Nothing val "") (unpack (toShortest val))