Chapter 5. The lang package: language support

Table of Contents
5.1. Addr
5.2. Bits
5.3. ByteArray
5.4. CCall
5.5. CError
5.6. CForeign
5.7. CTypes
5.8. CTypesISO
5.9. CString
5.10. DiffArray
5.11. Dynamic
5.12. Exception
5.13. Foreign
5.14. ForeignObj
5.15. ForeignPtr
5.16. GlaExts
5.17. IArray
5.18. Int
5.19. IOExts
5.20. LazyST
5.21. MArray
5.22. MarshalAlloc
5.23. MarshalArray
5.24. MarshalError
5.25. MarshalUtils
5.26. MutableArray
5.27. NumExts
5.28. PackedString
5.29. Ptr
5.30. ShowFunctions
5.31. ST
5.32. Stable
5.33. StableName
5.34. StablePtr
5.35. Storable
5.36. StorableArray
5.37. SystemExts
5.38. Weak
5.39. Word

5.1. Addr

This library is DEPRECATED. Use Ptr (see Section 5.29) instead.

5.1.1. Address Type and Arithmetic

data Addr      -- abstract handle for memory addresses
               -- instance of: Eq, Ord, Show, Typeable

nullAddr  :: Addr
alignAddr :: Addr -> Int  -> Addr
plusAddr  :: Addr -> Int  -> Addr
minusAddr :: Addr -> Addr -> Int

The following specifies the behaviour of the four function definitions.

nullAddr :: Addr

The constant nullAddr contains a distinguished value of Addr that is not associated with a valid memory location.

alignAddr :: Addr -> Int -> Addr

Given an arbitrary address and an alignment constraint, alignAddr yields the next higher address that fulfills the alignment constraint. An alignment constraint x is fulfilled by any address divisible by x. This operation is idempotent.

plusAddr :: Addr -> Int -> Addr

Advances the given address by the given address offset.

minusAddr :: Addr -> Addr -> Int

Computes the offset required to get from the first to the second argument. We have

   a2 == a1 `plusAddr` (a2 `minusAddr` a1)

5.1.2. The Standard C-side Interface

The following definition is available to C programs inter-operating with Haskell code when including the header HsFFI.h.

typedef void* HsAddr;  /* C representation of an Addr */