\section[PrelAddr]{Module @PrelAddr@}
\begin{code}
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-}
module PrelAddr (
Addr(..)
, Word(..)
, wordToInt
+ , intToWord
, Word64(..)
, Int64(..)
import PrelGHC
import PrelBase
-import PrelShow
-import PrelCCall
+
+infixl 5 `plusAddr`
\end{code}
\begin{code}
data Addr = A# Addr# deriving (Eq, Ord)
data Word = W# Word# deriving (Eq, Ord)
-instance Show Addr where
- showsPrec p (A# a) = showsPrec p (I# (addr2Int# a))
-
nullAddr :: Addr
-nullAddr = ``(W_)NULL''
+nullAddr = A# (int2Addr# 0#)
plusAddr :: Addr -> Int -> Addr
plusAddr (A# addr) (I# off) = A# (int2Addr# (addr2Int# addr +# off))
instance CCallable Addr
-instance CCallable Addr#
instance CReturnable Addr
instance CCallable Word
-instance CCallable Word#
instance CReturnable Word
wordToInt :: Word -> Int
wordToInt (W# w#) = I# (word2Int# w#)
+intToWord :: Int -> Word
+intToWord (I# i#) = W# (int2Word# i#)
+
#if WORD_SIZE_IN_BYTES == 8
data Word64 = W64# Word#
data Int64 = I64# Int#
#else
data Word64 = W64# Word64# --deriving (Eq, Ord) -- Glasgow extension
data Int64 = I64# Int64# --deriving (Eq, Ord) -- Glasgow extension
-
-instance CCallable Word64#
-instance CCallable Int64#
#endif
instance CCallable Word64