bindings-common-0.1.3: Low-level library bindings, base package.




data Storable a => GlobalVariable a Source

Haskell FFI imports global variables as pointers. To ease manipulation of such pointers they are encapsulated by GlobalVariable so that values can be reached directly, much like in an Data.IORef.

class Storable cb => Callback cb whereSource

When libraries provide types for functions those types are made instances of class Callback. That class is used to exchange between Haskell functions and a representation (i.e., a hidden pointer) that can be used or is provided by foreign code.

Associated Types

type F cb :: *Source

The associated type is the function type as it is used in Haskell.


nullCallback :: cbSource

nullCallback can be used like Foreign.Ptr.nullFunPtr.

makeCallback :: F cb -> IO cbSource

makeCallback takes a Haskell function and gives a representation of it in the form of the type expected by foreign code.

freeCallback :: cb -> IO ()Source

freeCallback should be called on all values returned by makeCallback after they are no longer going to be used. Most of the time this class method will just use Foreign.Ptr.freeHaskellFunPtr.

withCallback :: F cb -> (cb -> IO a) -> IO aSource

withCallback just inserts an action between calls to makeCallback and freeCallback. Of course, it can't be used when foreign code will save such action for latter use.