Next Previous Contents

2. Addr

This library provides machine addresses and is primarily intended for use in creating foreign function interfaces using GreenCard.

module Addr where
data Addr  -- Address type
instance Eq Addr
instance Ord Addr

nullAddr           :: Addr
plusAddr           :: Addr -> Int -> Addr

-- read value out of _immutable_ memory
indexCharOffAddr   :: Addr -> Int -> Char
indexIntOffAddr    :: Addr -> Int -> Int
indexAddrOffAddr   :: Addr -> Int -> Addr
indexFloatOffAddr  :: Addr -> Int -> Float
indexDoubleOffAddr :: Addr -> Int -> Double
indexWord8OffAddr  :: Addr -> Int -> Word8
indexWord16OffAddr :: Addr -> Int -> Word16
indexWord32OffAddr :: Addr -> Int -> Word32
indexWord64OffAddr :: Addr -> Int -> Word64
indexInt8OffAddr   :: Addr -> Int -> Int8
indexInt16OffAddr  :: Addr -> Int -> Int16
indexInt32OffAddr  :: Addr -> Int -> Int32
indexInt64OffAddr  :: Addr -> Int -> Int64

-- read value out of mutable memory
readCharOffAddr    :: Addr -> Int -> IO Char
readIntOffAddr     :: Addr -> Int -> IO Int
readAddrOffAddr    :: Addr -> Int -> IO Addr
readFloatOffAddr   :: Addr -> Int -> IO Float
readDoubleOffAddr  :: Addr -> Int -> IO Double
readWord8OffAddr   :: Addr -> Int -> IO Word8
readWord16OffAddr  :: Addr -> Int -> IO Word16
readWord32OffAddr  :: Addr -> Int -> IO Word32
readWord64OffAddr  :: Addr -> Int -> IO Word64
readInt8OffAddr    :: Addr -> Int -> IO Int8
readInt16OffAddr   :: Addr -> Int -> IO Int16
readInt32OffAddr   :: Addr -> Int -> IO Int32
readInt64OffAddr   :: Addr -> Int -> IO Int64

-- write value into mutable memory
writeCharOffAddr   :: Addr -> Int -> Char   -> IO ()
writeIntOffAddr    :: Addr -> Int -> Int    -> IO ()
writeAddrOffAddr       :: Addr -> Int -> Addr   -> IO ()
writeForeignObjOffAddr :: Addr -> Int -> ForeignObj -> IO ()
writeFloatOffAddr  :: Addr -> Int -> Float  -> IO ()
writeDoubleOffAddr :: Addr -> Int -> Double -> IO ()
writeWord8OffAddr  :: Addr -> Int -> Word8  -> IO ()
writeWord16OffAddr :: Addr -> Int -> Word16 -> IO ()
writeWord32OffAddr :: Addr -> Int -> Word32 -> IO ()
writeWord64OffAddr :: Addr -> Int -> Word64 -> IO ()
writeInt8OffAddr   :: Addr -> Int -> Int8   -> IO ()
writeInt16OffAddr  :: Addr -> Int -> Int16  -> IO ()
writeInt32OffAddr  :: Addr -> Int -> Int32  -> IO ()
writeInt64OffAddr  :: Addr -> Int -> Int64  -> IO ()

Hugs provides Addr and nullAddr but does not provide any of the index, read or write functions. They can be implemented using GreenCard if required.


Next Previous Contents