C->Haskell FFI tool that gives some cross-language type safety https://github.com/haskell/c2hs

Version on this page:0.25.2
LTS Haskell 11.10:0.28.3
Stackage Nightly 2018-05-20:0.28.3
Latest on Hackage:0.28.3

See all snapshots c2hs appears in

GPL-2 licensed by Manuel M T Chakravarty
Maintained by chak@cse.unsw.edu.au, duncan@community.haskell.org, ian@skybluetrades.net, aditya.siram@gmail.com

Module documentation for 0.25.2

There are no documented modules for this package.

Compiler Toolkit - Light -*-text-*-


README.CTKlight -- This file
LICENSE.LIB -- GNU Library General Public License (LGPL)
BaseVersion.hs -- Version, copyright, and disclaimer
Config.hs -- Configuration module
Common.hs -- Basic definitions, such as representation of positions
DLists.hs -- Difference lists - provide O(1) append
Errors.hs -- Types and functions for error handling
FNameOps.hs -- Common operations on file names
FiniteMaps.hs -- Finite maps based on 2-3 trees
GetOpt.hs -- Sven Panne's Haskell version of the GNU getopt library
Lexers.hs -- Self-optimising lexer combinators
Parsers.hs -- Self-optimising parser combinators
Pretty.hs -- Pretty printing combinators (the interface is essentially
a superset of SimonPJ's pretty printing library)
Sets.hs -- Sets as an instance of the above mentioned finite maps
Utils.hs -- Utility routines

The Compiler Toolkit Light (CTKlight) is a subset of the Compiler Toolkit
(CTK) - an infrastructure for writing compilers in Haskell. CTKlight
essentially provides support for implementing syntactical analysis without the
more heavy-weight state management (like compiler switches, global error pool,
and exceptions), identifier and attribute management, and various other
utilities included in the full CTK. Both packages can be obtained from


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- BUILDING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

In contrast to full CTK, CTKlight is simply a set of Haskell modules without
any complicated makefile structure. The code is Haskell 98 compliant with the
exception that `Parser.hs' makes use of existentially quantified type
variables - unfortunately, I do not believe that the same method of
self-optimisation would work without existential types.

The modules are tested with

* GHC 4.02 and upwards (use `-fglasgow-exts' to compile `Parsers.hs') and
* Hugs98 (use `-98' when using `Parsers.hs').

If you want autoconf, a ready-made makefile structure, and much more
additional library functionality, then use full CTK.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- COPYLEFT -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.

This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more

You should have received a copy of the GNU Library General Public License
along with this system; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.

Note: In essence this means that you can use this library in any program
whether it is free or proprietary. However, if you modify or extend the
library itself, you are bound to distribute these modifications or
extensions according to the terms and conditions of the LGPL. For
details consult the license itself, which is located in the file

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CREDITS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Author & Maintainer: Manuel M. T. Chakravarty <chak@cse.unsw.edu.au>

Thanks to Simon L. Peyton Jones <simonpj@microsoft.com> and Roman Lechtchinsky
<wolfro@cs.tu-berlin.de> for their helpful suggestions that improved the
design and implementation of the `Lexers' module.


- Switch to language-c 0.7.1 [#192]
- Switch to language-c 0.6 [#176]
- Switch to language-c 0.5 [#157]
- Fix class hook problem with imports [#155]

- Alternate specification for sizes in "+" parameters [#140]
- Fix regression to do with incomplete structure types [#152]
- Fix pattern match error [PR #153] (deech)

- Missing import bug [#151]
- Parameter count checking for {#fun ...#} [#149]
- Error message for "incomplete types" [#141]

- Better error messages [PR #139] (Noam Lewis)
- Fix for OS X block syntax [#138] (Anthony Cowley)
- Minimal support for va_list [PR #137] (Andy Adams-Moran)
- Reorganise treatment of standard library imports used by C2HS
[#136] (https://github.com/haskell/c2hs/blob/master/import-handling.md)
- C structure tag/typedef confusion bug (caused problems for flock on
OS X) [#134]
- C typedefs to void pointers [#133]
- Bool wrappers for unnamed parameters in C function definitions
- Incorrect wrapping of some pure C functions [#130]

- Test fixes to work with GHC 7.10.1

- Marshalling for C bool values [#128]

- Revert bad fix for bool handling [#127]
- Wrapper generation for bare structure arguments [#117] plus custom
setup script to support Cabal builds on versions of Cabal without
explicit support for extra C sources generated by preprocessors
- Arrays in structuress bug [#123]
- Test fixes for Windows

- Typedef and default marshalling hooks [#20, #25, #48]
- Test fixes for 32-bit platforms (J├╝rgen Keck: @j-keck)
- Multi-character constants for OS X [#15]
- Better support for binding to variadic functions [#102]

- First (not very good) implementation of support for variadic
functions [#102]
- Default marshallers for Char types [#98]
- Improve sizeof computations [#9, #10]

- Parametrized pointer types in pointer hooks [#36]
- Special "+" parameters for efficient foreign pointer marshalling [#46]
- Add default marshallers for C types [#83]
- Fix treatment of arrays within structs [#115]
- Add ability to omit given enum values [#116]
- Regression suite tidy-ups

- Get CUDA Travis tests working again (hopefully...)
- Modify approach for defining C2HS_MIN_VERSION macro to work with
NVIDIA's nvcc CUDA compiler [#111]
- Fix problem with parser for {#enum ...#} renamings [#113]

- Add {#const ...#} hook for accessing #defined constants [#65]
- Persist enumeration definitions across modules [#103]
- Add nocode keyword for enumeration definitions [#70]
- Bump version for language-c to fix OS X problems [#82, #85] (thanks to
Anthony Cowley and Benedikt Huber for help with this)
- Add finalizer support to foreign pointer definitions [#73]
- Comment parsing cleanups (Sivert Berg: @sivertb)

- Add C2HS_MIN_VERSION(major,minor,revision) preprocessor macro
- Suppress regression suite build (and associated dependency
installation) for non-Travis cases
- Fix Cabal file to include previously missing tests

- Numerous improvements to Enum handling [#78] (Philipp Balzarek:
- Handle Haddock comments within C2HS hook definitions [#62] (@tangboyun)
- Better error messages for missing files (Zejun Wu: @watashi)
- Write CHS dump files to output directory (Zejun Wu: @watashi)
- Handle C calling conventions within function pointer declarations [#88]
(Michael Steele: @mikesteele81)
- Fix FreeBSD libssh2 problem [#87] (Cindy Wang: @CindyLinz)
- Better error messages for hook syntax errors (Ryan Scott: @RyanGIScott)
- Fixes for GHC 7.9 [#100] (@int-index)
- Fix test suite to use C2HS from dist directory [#81]
- Allow free intermixing of command line options and input files [#86]
- Treat CLang "block" syntax and other "non-GNU" issues differently:
always undefine __BLOCKS__ CPP symbol to avoid problems with blocks;
add nonGNU directive to trigger undefine of GNU-specific pre-processor
symbols [#77]
- Handle indented CPP directives correctly [#80]
- Handle #sizeof and #alignof on non-typedef's structures [#95]
- Fix #get and #set hooks to access newtyped pointers [#96]
- Fix round-trip problem for interface files caused by changes in
language-c [#87]
- Treat "with" specially so that it can appear both as a marshaller
identifier in an input parameter definition and as a keyword in enum
definitions [#93]
- Temporarily disable CUDA regression suite examples (CUDA install
problems on Travis)

- Fix more regressions from 0.16.6 (affected packages included
gnome-keyring, hsndfile and cuda)
- Add regression suite tests to reduce chances of future regressions


- Fix regressions from 0.16.6 (caused by fix for issue #45)
- Version number bump (should have been done in the last release)


- Trivial integer casts in enum defines supporting typedefs [Anton Dessiatov]
- Allow forward definition of enums (issue #23)
- Binding of C enums with aliases (issue #38)
- Default marshallers for enum and pointer hooks (issue #31)
- Remove dependencies on C2HS module from marshalling code (issue #37)
- Problem with MacOS blocks notation (issue #29)
- Include directive on first line produces invalid Haskell (issue #16)
- Add command-line switch to suppress GNU preprocessor symbols (issue #60)
- Fix size and alignment computation of bitfields [Facundo Dominguez]
- Allow prefixes to be replaced, not just removed (issue #19)
- Allow reference to structure tags from accessors (issue #54)
For access paths for {#get#}, {#set#}, etc., one can now specify
that structure tags are to be searched preferentially by saying,
for example, {#get struct _point->y#} instead of {#get _point->y#}.
The latter case will search for typedef names first and only then
structure tags.
- Support for anonymous enums (issue #43)
- with... unwrapper type declarations for pointer hooks (issue #44)
- {#fun...#} indentation for use in where clauses (issue #45)
- incorrect method names from terminal class in superclass
instances (issue #21)
- "offsetof" directive (issue #22)
- --include flag cannot handle windows paths (issue #30)
Now uses System.FilePath splitSearchPath function, which should be
- Void functions produce "defined but not used" warning (issue #47)
Handle fun hooks with a void result using ">>" instead of ">>=".
- Add CPP undefine flags for Gnu compiler defines (issue #51)
- Cabal test suite


- Migration to GitHub; documentation changes.

comments powered byDisqus