>The Green Card User's Guide

The Green Card User's Guide

The Green Card Team

June 2001

This document describes Green Card, a foreign language interface preprocessor for Haskell, version 2.0. It is based on the Green Card paper presented at the '97 Haskell Workshop by Simon Peyton Jones simonpj@dcs.gla.ac.uk and Thomas Nordin nordin@cse.ogi.edu.


Table of Contents
1. Introduction
2. Goals and non-goals
3. Foreign language interfaces are harder than they look
4. Overview of Green Card
5. Green Card directives
6. Procedure specifications
7. Type signature
8. Automatic fill-in
9. Data Interface Schemes
10. Standard DISs
11. Imports
12. Invoking Green Card
13. Related Work
14. Alternative design choices and avenues for improvement
15. Using Green Card

1. Introduction

A foreign-language interface provides a way for software written in a one language to interact with code written in another. Programming languages that lack foreign-language interfaces die a lingering death.

All Haskell implementations known to us do provide facilities for interfacing to external functionality. For instance, the Glasgow Haskell compiler (GHC) provides a ccall construct for mixing calls to C functions with standard Haskell code performing I/O. However, the mechanism is low-level and it often requires the programmer to write lots of tedious boilerplate code to convert Haskell values into the representations expected by the external function.

We present here Green Card, a preprocessor for Haskell that tries to simplify the task of defining an interface/binding to foreign functionality.