-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Memory reinterpretation casts for Float/Double and Word32/Word64
--   
--   Memory reinterpretation casts for Float/Double and Word32/Word64.
--   
--   The implementations in the .Internal package are different
--   ways to tackle the problem; the array method (current
--   default) is about 5 times faster than the FFI method.
@package reinterpret-cast
@version 0.1.0

-- | This is the array approach.
--   
--   Implements casting via a 1-elemnt STUArray, as described in
--   http://stackoverflow.com/a/7002812/263061.
module Data.ReinterpretCast.Internal.ImplArray

-- | Reinterpret-casts a Float to a Word32.
floatToWord :: Float -> Word32

-- | Reinterpret-casts a Word32 to a Float.
wordToFloat :: Word32 -> Float

-- | Reinterpret-casts a Double to a Word64.
doubleToWord :: Double -> Word64

-- | Reinterpret-casts a Word64 to a Double.
wordToDouble :: Word64 -> Double

-- | Memory reinterpretation casts for Float/Double and Word32/Word64.
--   
--   Currently we use the array method from
--   http://stackoverflow.com/a/7002812/263061.
--   
--   If you need something like Int32 or similar,
--   fromIntegral will do the job within the integral types (so
--   to/from Word* are the only conversions needed).
module Data.ReinterpretCast

-- | Reinterpret-casts a Float to a Word32.
floatToWord :: Float -> Word32

-- | Reinterpret-casts a Word32 to a Float.
wordToFloat :: Word32 -> Float

-- | Reinterpret-casts a Double to a Word64.
doubleToWord :: Double -> Word64

-- | Reinterpret-casts a Word64 to a Double.
wordToDouble :: Word64 -> Double

-- | This is the FFI approach.
--   
--   Implements casting via the FFI, using alloca like in
--   http://hackage.haskell.org/package/data-binary-ieee754.
module Data.ReinterpretCast.Internal.ImplFFI

-- | Reinterpret-casts a Float to a Word32.
floatToWord :: Float -> Word32

-- | Reinterpret-casts a Word32 to a Float.
wordToFloat :: Word32 -> Float

-- | Reinterpret-casts a Double to a Word64.
doubleToWord :: Double -> Word64

-- | Reinterpret-casts a Word64 to a Double.
wordToDouble :: Word64 -> Double
