[project @ 2000-04-10 16:02:58 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / PrelAddr.lhs
index b334fd0..8a0ba32 100644 (file)
@@ -5,7 +5,7 @@
 \section[PrelAddr]{Module @PrelAddr@}
 
 \begin{code}
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS -fcompiling-prelude -fno-implicit-prelude #-}
 
 module PrelAddr (
          Addr(..)
@@ -15,6 +15,7 @@ module PrelAddr (
 
        , Word(..)
        , wordToInt
+       , intToWord
 
        , Word64(..)
        , Int64(..)
@@ -22,17 +23,14 @@ module PrelAddr (
 
 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 = A# (int2Addr# 0#)
 
@@ -40,25 +38,23 @@ 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