Ryan Ingram <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in 
gmane.comp.lang.haskell.cafe:
> Actually, this is a good question, at least as relating to floating
> point values.  Is there a primitive to view the machine representation
> of floats?

Not a primitive, but it can be defined:

module Cast (cast) where

import Foreign.Storable (Storable, sizeOf, peek)
import Foreign.Marshal.Utils (with)
import System.IO.Unsafe (unsafePerformIO)
import Foreign.Ptr (castPtr)

cast :: (Storable a, Storable b) => a -> b
cast a = b where
  b | sizeOf a == sizeOf b = unsafePerformIO $ with a $ peek . castPtr

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Don't mess with me lady; I've been drinking with skeletons.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to