ContentsQuick linksExternal |
C->Haskell, An Interface Generator for Haskell
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. The idea for the tool was developed during the implementation of Gtk+HS, a Haskell binding for the GUI toolkit GTK+. The latter is no longer under active development, but its successor, Gtk2Hs, also uses C->Haskell. The latest news:
Currently, the C->Haskell compiler is available for the Glasgow Haskell Compiler only. However, the only extension needed over Haskell 98 and the H98 FFI Addendum are existential data types. (The latter are only needed for the C->Haskell compiler itself, but not for the accompanying marshaling libraries.) Partial support for nhc98 is in place, but so far there have always been some bugs in nhc98 that prevented to complete the port. DownloadThe code is available from hackage. Mailing ListTo subscribe to the C->Haskell mailing list, visit the subscription page. The address of the list is c2hs@haskell.org and there is also an online archive. Darcs RepositoryFor those living on the bleeding edge of development, get the latest C->Haskell code per darcs with darcs get http://darcs.haskell.org/c2hs/
Inside your copy of the repository, execute NB for Mac users: One of the patches originating from the cvs to darcs conversion of the repository seems to cause problems on Macs (due to the lack of case distinction in file names). The patch can be circumvented by getting a partial repository as follows: darcs get --partial http://darcs.haskell.org/c2hs/ Bug reports and feature requestsWe'll use Trac to track bugs and feature requests in the future. DocumentationIf you plan to install C->Haskell, you probably like to read the C->Haskell Tutorial. There is also a research paper about the tool. To get an idea of how to use the interface generator -- after the build -- go to the directory c2hs/tests/, which contains a number of small examples of binding files with matching C header files. Most interesting is Structs.chs as well as Pointer.chs as well as the corresponding C source and header files. The binding file contains instructions on how to generate an executable from it. Yaakov Nemoy published a hands-on blog article on using C->Haskell: Haskell Bindings to C from Start to Finish. Future Development
If you have any comments, suggestions, or a bug report, please send them
to LicenseThe code is released under the GNU General Public Licence (GPL). This means that you can basically do with it what you want as long as you contribute improvements of the tool itself back to the community. Any interfaces that you generate with the tool are, however, free from any license restrictions from my side. The situation is exactly the same as with the GNU C Compiler (gcc). |
| • Copyright [2005..2009] Manuel M T Chakravarty • Last modified: 1 March 2009 • |