[commit: packages/binary] master: Only layout changes (ef18f42)
git at git.haskell.org
git at git.haskell.org
Sat Feb 4 21:17:52 UTC 2017
Repository : ssh://git@git.haskell.org/binary
On branch : master
Link : http://git.haskell.org/packages/binary.git/commitdiff/ef18f42da2d67bdbe0ede2c23d911218761fbb43
>---------------------------------------------------------------
commit ef18f42da2d67bdbe0ede2c23d911218761fbb43
Author: Daniel Díaz <dhelta.diaz at gmail.com>
Date: Tue May 31 13:12:49 2016 -0400
Only layout changes
>---------------------------------------------------------------
ef18f42da2d67bdbe0ede2c23d911218761fbb43
src/Data/Binary/FloatCast.hs | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/src/Data/Binary/FloatCast.hs b/src/Data/Binary/FloatCast.hs
index 31ed0a0..65f876e 100644
--- a/src/Data/Binary/FloatCast.hs
+++ b/src/Data/Binary/FloatCast.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE FlexibleContexts #-}
--- | This module is a literal copy of
+-- | This module was written based on
-- <http://hackage.haskell.org/package/reinterpret-cast-0.1.0/docs/src/Data-ReinterpretCast-Internal-ImplArray.html>.
--
-- Implements casting via a 1-elemnt STUArray, as described in
@@ -13,42 +13,32 @@ module Data.Binary.FloatCast
, wordToDouble
) where
-
import Data.Word (Word32, Word64)
import Data.Array.ST (newArray, readArray, MArray, STUArray)
import Data.Array.Unsafe (castSTUArray)
import GHC.ST (runST, ST)
-
-- | Reinterpret-casts a `Float` to a `Word32`.
floatToWord :: Float -> Word32
floatToWord x = runST (cast x)
-
{-# INLINE floatToWord #-}
-
-- | Reinterpret-casts a `Word32` to a `Float`.
wordToFloat :: Word32 -> Float
wordToFloat x = runST (cast x)
-
{-# INLINE wordToFloat #-}
-
-- | Reinterpret-casts a `Double` to a `Word64`.
doubleToWord :: Double -> Word64
doubleToWord x = runST (cast x)
-
{-# INLINE doubleToWord #-}
-
-- | Reinterpret-casts a `Word64` to a `Double`.
wordToDouble :: Word64 -> Double
wordToDouble x = runST (cast x)
-
{-# INLINE wordToDouble #-}
-
-{-# INLINE cast #-}
cast :: (MArray (STUArray s) a (ST s),
MArray (STUArray s) b (ST s)) => a -> ST s b
cast x = newArray (0 :: Int, 0) x >>= castSTUArray >>= flip readArray 0
+{-# INLINE cast #-}
More information about the ghc-commits
mailing list