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 generator is implemented using the Compiler Toolkit and in particular the self-optimising lexer and parser combinators of the toolkit. The use of the toolkit simplified the implementation of C->Haskell considerably. 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. Current Status
Most of the major features that I have planned for C->Haskell are
implemented and are working. The system has an easy to use build system
(Cabal-style ReleasesThe following lists source and binary packages of C->Haskell. Note that the binary packages are compiled for use with GHC and that the included marshalling libraries will only work with exactly the version of GHC that they have been compiled for.
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/ Online viewing: If you like to query the C->Haskell repository without making a local copy, try the darcs repository viewer. RSS feed: Repository change messages are also available via rss. Bug reports and feature requestsWe'll use Trac to track bugs and feature requests in the future. (Not much there yet.) 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. Future DevelopmentThe current version is slated to become version 1.0 after some small extensions and some more testing.
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..2006] Manuel M T Chakravarty • Last modified: Tue Jan 2 13:15:19 EST 2007 • |