# The Binding Generator C->Haskell

## Manuel M. T. Chakravarty, `chak@cse.unsw.edu.au`

v0.22, 12 December 2005

C->Haskell is an interface generator that simplifies the development of Haskell bindings to C libraries. The tool processes existing C header files that determine data layout and function signatures on the C side in conjunction with Haskell modules that specify Haskell-side type signatures and marshaling details. Hooks embedded in the Haskell code signal access to C structures and functions -- they are expanded by the interfacing tool in dependence on information from the corresponding C header file. Another noteworthy property is the lightweight nature of the approach. More background information is available in a research paper discussing C->Haskell, which is at http://www.cse.unsw.edu.au/~chak/papers/papers.html#c2hs. However, this paper does not cover the more recent advanced features such as function hooks and conditional compilation.

Copyright & Distribution

Copyright (c) [1999..2005] by Manuel M. T. Chakravarty. The manual is distributed under the terms GNU Free Documentation License available from http://www.fsf.org/copyleft/fdl.html.

The master copy of this document is at http://www.cse.unsw.edu.au/~chak/haskell/c2hs/; the source is in SGML, which allows you to produce a selection of standard formats, including HTML and Postscript.

Contributions

If you have any comments, suggestions, or contributions, please send them to chak@cse.unsw.edu.au.

### 1. Installation

  1.1. Where is the Source?
  1.2. What Else Do I Need?
  1.3. I Got Everything, and Now?
  1.4. Usage of `c2hs`
  1.5. Compilation of a Generated Haskell API

### 2. Implementation of Haskell Binding Modules

  2.1. Import Hooks
  2.2. Context Hooks
  2.3. Type Hooks
  2.4. Sizeof Hooks
  2.5. Enumeration Hooks
  2.6. Call Hooks
  2.7. Function Hooks
  2.8. Get Hooks
  2.9. Set Hooks
  2.10. Pointer Hooks
  2.11. Class Hooks
  2.12. CPP Directives and Inline C Code
  2.13. Grammar Rules

### 3. The Haskell FFI Marshalling Library

### 4. Bug Reports and Suggestions

### 5. Copyright

  5.1. C->Haskell License
  5.2. Documentation License
  5.3. Possible Licenses of Generated Code

### 6. GNU Free Documentation License

### 7. Release Notes

  7.1. Version 0.14.5 "Travelling Lightly"
  7.2. Version 0.13.6 "Pressing Forward"
  7.3. Version 0.12.1 "Springtime"
  7.4. Version 0.11.5 "Powder Snow"
  7.5. Version 0.10.17 "Altocumulus Stratiformis Perlucidus Undulatus"
  7.6. Version 0.9.9 "Blue Ginger"
  7.7. Version 0.8.2 "Gentle Moon"
  7.8. Version 0.8.1 "Gentle Moon"
  7.9. Version 0.7.10 "Afterthought"
  7.10. Version 0.7.9 "Afterthought"
  7.11. Version 0.7.8
  7.12. Version 0.7.7
  7.13. Version 0.7.6
  7.14. Version 0.7.5