[project @ 1998-07-08 10:00:17 by sof]
authorsof <unknown>
Wed, 8 Jul 1998 10:00:17 +0000 (10:00 +0000)
committersof <unknown>
Wed, 8 Jul 1998 10:00:17 +0000 (10:00 +0000)
Int <-> Addr (non-std) conversions

ghc/lib/exts/Addr.lhs

index b9b789c..19636d7 100644 (file)
@@ -10,6 +10,10 @@ module Addr
        , module Word
        , module Int
        , module Addr 
+       
+        -- (non-standard) coercions
+       , addrToInt             -- :: Addr -> Int  
+       , intToAddr             -- :: Int  -> Addr
            
        ) where
 
@@ -34,6 +38,16 @@ import Int   ( indexInt8OffAddr,  indexInt16OffAddr
 
 \end{code}
 
+Coercing between machine ints and words
+
+\begin{code}
+addrToInt :: Addr -> Int
+addrToInt (A# a#) = I# (addr2Int# a#)
+
+intToAddr :: Int -> Addr
+intToAddr (I# i#) = A# (int2Addr# i#)
+\end{code}
+
 Indexing immutable memory:
 
 \begin{code}