Int <-> Addr (non-std) conversions
, module Word
, module Int
, module Addr
+
+ -- (non-standard) coercions
+ , addrToInt -- :: Addr -> Int
+ , intToAddr -- :: Int -> Addr
) where
\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}