From ef6dd2be061f3204b535f7dc3c2679e0573b3724 Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 8 Jul 1998 10:00:17 +0000 Subject: [PATCH] [project @ 1998-07-08 10:00:17 by sof] Int <-> Addr (non-std) conversions --- ghc/lib/exts/Addr.lhs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ghc/lib/exts/Addr.lhs b/ghc/lib/exts/Addr.lhs index b9b789c..19636d7 100644 --- a/ghc/lib/exts/Addr.lhs +++ b/ghc/lib/exts/Addr.lhs @@ -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} -- 1.7.10.4