-- 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 <tt>.Internal</tt> package are different
--   ways to tackle the problem; the <tt>array</tt> method (current
--   default) is about 5 times faster than the <tt>FFI</tt> method.
@package reinterpret-cast
@version 0.1.0


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

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

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

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

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


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

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

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

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

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


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

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

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

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

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