Next Previous Contents

6.1 Interfacing with C header files

One of HaskellDirect's front-ends support DCE IDL, which is syntactically extremely close to C prototype and type declarations in the sense that a C header file can be viewed as low-quality IDL input.

HaskellDirect supports the reading of header files together with a number of mechanisms to help you improve on the information that header file declaration conveys. To elucidate how HaskellDirect can be used, here's a set of steps you will commonly have to go through to import into Haskell the functionality specified in a header file.

By following the above three steps, HaskellDirect should have generated CoolAPI.hs, which contains the necessary type and function stub definitions. However, more often than not, these stubs are less than satisfactory, for a number of reasons:

As a parting remark, it is the author's experience that it is often easy to fall into the trap of spending lots of effort in trying to supply the set of IDL attributes that makes the generated stubs look just right to the Haskell programmer. If you find yourself in this situation, it may be worth considering whether you should instead shift some of the responsibility of providing a Haskell-friendly veneer to the external API into Haskell itself, i.e., write the impedance matching code yourself.


Next Previous Contents