Ptr
This module provides typed pointers to foreign data. It is part of the Foreign Function Interface (FFI) and will normally be imported via the Foreign module.
A value of type Ptr a represents a pointer to an object, or an array of objects, which may be marshalled to or from Haskell values of type a.
The type a will often be an instance of class Foreign.Storable.Storable which provides the marshalling operations. However this is not essential, and you can provide your own operations to access the pointer. For example you might write small foreign functions to get or set the fields of a C struct.
casts a Ptr to an IntPtr
casts a Ptr to a WordPtr
This function adds a finalizer to the given foreign object. The finalizer will run before all other finalizers for the same object which have already been registered.
This function adds a finalizer to the given ForeignPtr. The finalizer will run after the last reference to the foreign object is dropped, but before all previously registered finalizers for the same object.
Advance a pointer into an array by the given number of elements
Given an arbitrary address and an alignment constraint, alignPtr 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.
This function casts a ForeignPtr parameterised by one type into another type.
Casts a FunPtr to a Ptr.
Note: this is valid only on architectures function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.
The castPtr function casts a pointer from one type to another.
Casts a Ptr to a FunPtr.
Note: this is valid only on architectures function pointers range over the same set of addresses, and should only be used for bindings to external libraries whose interface already relies on this assumption.
Coerce a stable pointer to an address. No guarantees are made about the resulting value, except that the original stable pointer can be recovered by castPtrToStablePtr. In particular, the address may not refer to an accessible memory location and any attempt to pass it to the member functions of the class Foreign.Storable.Storable leads to undefined behaviour.
Haskell type representing the C ptrdiff_t type.
Show more results