This document describes how to use HaskellDirect (HDirect), a foreign function interface framework for Haskell. HDirect is based around the use of an Interface Definition Language (IDL) to specify a programming interface in a programming language independent manner. Why is this of use to the Haskell programmer?
By describing the set of functions exported by some library using IDL, the HDirect IDL compiler takes care of generating the necessary Haskell (low-level) function stubs that lets you access these external functions from within your Haskell code.
The compiler supports two flavours of IDL for this, DCE IDL syntax (as used by OSF DCE and the Microsoft IDL compiler) and the OMG CORBA IDL.
Going the other way, IDL can also be used to specify Haskell functions that you want to export to the outside world, e.g., you want to be able to use Haskell code from within your user interface, which is implemented in C, say. HDirect supports this too, generating the necessary proxies that gives the Haskell functions a C compatible calling interface.
A special case of the first point, but a quite important one. When the IDL specification represents a set of COM interfaces, HDirect generates special versions of the Haskell stub functions that lets you use COM objects from within Haskell.
HaskellDirect supports the same IDL syntax as the Microsoft IDL compiler (MIDL) for describing COM components, but it generates a mapping for Haskell rather than C/C++.
This document introduces the various features of IDL and what it corresponds to in Haskell by a series of examples, covering the different modes of operation just outlined. An exact definition of IDL is not presented, instead we introduce the features you're most likely to need by way of examples, but give instead pointers to IDL specifications and other resources at the end.
But, before presenting examples of IDL can be made use of, let's start off by motivating the need for IDL and HaskellDirect a little.