Preface

The definition of Haskell 98 [7], while being comprehensive with respect to the functional core language, does lack a range of features of more operational flavour, such as a foreign language interface, concurrency support, and fully fledged exception handling. As these features are of central importance to many real world applications of the language, there is a danger that different implementations become de facto incompatible for such applications due to system-specific extensions of the core language. The present FFI specification is aimed at reducing this risk by defining a simple, yet comprehensive extension to Haskell 98 for the purpose of interfacing to program components implemented in a language other than Haskell.

The goal behind this foreign function interface (FFI) specification is twofold: It enables (1) to describe in Haskell the interface to foreign functionality and (2) to use from foreign code Haskell routines. More precisely, its aim is to support the implementation of programs in a mixture of Haskell and other languages such that the source code is portable across different implementations of Haskell and non-Haskell systems as well as independent of the architecture and operating system.

The design as presented in this report builds on experiences with a number of foreign function interfaces that, over time, have been provided by the major Haskell implementations. Central in the final design was the goal to be comprehensive while being simple and minimising changes with respect to Haskell 98; the latter includes to avoid pollution of the name space with new keywords. Consequently, as much as possible of the FFI functionality is realised in the form of libraries. Simplicity generally overruled maximum convenience for the programmer as a design goal. Thus, support for more convenient interface specifications is the domain of system-independent tools that generate code following the present specification.

Acknowledgements

We heartily thank the kind people who assisted us with their comments and suggestions on the ffi@haskell.org and haskell@haskell.org mailing lists as well as all the users of previous versions of the FFI who helped to shape the development by their feedback. We thank Olaf Chitil, Peter Gammie, Wolfram Kahl, Martin D. Kealey, Ian Lynagh, John Meacham, Ross Paterson, George Russell, and Wolfgang Thaller for errata and additions to previous versions of this report.