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

Bindings.Utilities

Synopsis

Documentation

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.

Methods

nullCallback :: cbSource

nullCallback can be used like Foreign.Ptr.nullPtr or 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 members of a foreign function type after they are no longer going to be used.

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 the function for latter use.