Green Card reads from standard input if no filename is given. The options
can be any of those:
-?, -h, --help
Print a usage message listing all available options, then exit successfully.
Print the version number, then exit successfully.
Print more information while processing the input.
Output extra debug information.
-i <directories>, --include-dir=<directories>
Search the directories named in the colon (:) separated list for
imported files. The directories will be searched in a left to right order.
-s <sufs>, --suffix=<sufs>
When searching, use colon separated list of source file suffixes (standard: no suffix or .gc)
-t <target>, --target=<target>
Generate Haskell code for a particular system. Targets currently
supported: ghc, hugs, nhc, and
ffi. You're encouraged to use the ffi target,
since the Haskell output it generates can be used with all Haskell
systems that support the common FFI (as of June 2001, all of them).
Generates code that can use callbacks to Haskell (GHC only.) This
makes the generated code slower (but safer!). See
Section 7.2 for details.
Put C code in a separate file (GHC target only.)
Generate Haskell 1.4 compatible instead of Haskell 98.
-m <scheme>, --name-mangling-scheme=<scheme>
Control how you mangle external names into Haskell ones. Schemes
currently supported: std and classic. The default is
std mangling, which will just change the casing of the first
Green Card will create one or more output files when running.
The following options control where the output goes:
-o <file>, --output=<file>
where to put generated Haskell file.
-c <file>, --output-c=<file>
where to put generated C file (if any header files are generated,
they'll go in (dropSuffix file ++ ".h").
-p <pre>, --output-prefix=<pre>
Use <prefix> as stem when generating output filenames that haven't
been specificed directly, i.e., using -p Right, the
Haskell and C output will be output in Right.hs and
If none of the above output options are used, the name of the output
files are constructed from the name of the input file. The filename
suffix is dropped and the appropriate suffix is appended, e.g.,
running Green Card on foo.gc will create a Haskell file called
When working with GHC, a commonly occurring problem for Green Card
generated code is that of functions being called unsafely when they
should have been called safely. The manifestation of this is as an
almighty crash. To help debug this, Green Card supports the option
--stub-debug which will emit debug code into the generated
code. For instance, for the following procedure specification:
On top of the normal boilerplate gubbins, the variable
__current_fun__ is assigned (Green Card doesn't
define this variable, so you'll have to define it yourself.)
Using __current_fun__, it is possible to catch unsafe
calls that really should have been safe. Here's how a Win32
library catches this condition in the (C wrapper) for its