haskell2010-1.0.0.0: Compatibility with Haskell 2010

Foreign.Ptr

Contents

Description

The module Foreign.Ptr provides typed pointers to foreign entities. We distinguish two kinds of pointers: pointers to data and pointers to functions. It is understood that these two kinds of pointers may be represented differently as they may be references to data and text segments, respectively.

Synopsis

Data pointers

Function pointers

freeHaskellFunPtr :: FunPtr a -> IO ()Source

Release the storage associated with the given FunPtr, which must have been obtained from a wrapper stub. This should be called whenever the return value from a foreign import wrapper function is no longer required; otherwise, the storage it uses will leak.

Integral types with lossless conversion to and from pointers

data IntPtr Source

A signed integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type intptr_t, and can be marshalled to and from that type safely.

ptrToIntPtr :: Ptr a -> IntPtrSource

casts a Ptr to an IntPtr

intPtrToPtr :: IntPtr -> Ptr aSource

casts an IntPtr to a Ptr

data WordPtr Source

An unsigned integral type that can be losslessly converted to and from Ptr. This type is also compatible with the C99 type uintptr_t, and can be marshalled to and from that type safely.

ptrToWordPtr :: Ptr a -> WordPtrSource

casts a Ptr to a WordPtr

wordPtrToPtr :: WordPtr -> Ptr aSource

casts a WordPtr to a Ptr