Skip to content
Snippets Groups Projects
Commit 25ee7c9e authored by chak@cse.unsw.edu.au.'s avatar chak@cse.unsw.edu.au.
Browse files

[project @ 2000-06-21 09:13:09 by chak]

As suggested by SimonM, moved an overview over the three components of the FFI
into the FFI document included as Chapter 7 into the GHC user guide.

Open questions:

* How can I make cross references to the doc in hslibs/?  There are already
  references to hslibs sections in other parts of ghc's user guide, but they
  are not correctly resolved when I generate html from the sgml files.

* There is now a (little) overlap with material in 6.5 (GHC Language Features:
  The foreign interface).  I would say, we could actually leave this as it is,
  as 6.5 goes on to describe GHC specifics.
parent 8933d145
No related merge requests found
...@@ -3,28 +3,76 @@ ...@@ -3,28 +3,76 @@
</Title> </Title>
<Para> <Para>
The motivation behind this foreign function interface(FFI) The motivation behind this foreign function interface (FFI) specification is
specification is to make it possible to describe in Haskell <Emphasis>source to make it possible to describe in Haskell <Emphasis>source code</Emphasis>
code</Emphasis> the interface to foreign functionality in a Haskell system the interface to foreign functionality in a Haskell system independent
independent manner. It builds on experiences made with the previous manner. It builds on experiences made with the previous foreign function
foreign function interfaces provided by GHC and Hugs. interfaces provided by GHC and Hugs. However, the FFI specified in this
document is not in the market of trying to completely bridge the gap between
the actual type of an external function, and what is a
<Emphasis>convenient</Emphasis> type for that function to the Haskell
programmer. That is the domain of tools like HaskellDirect or Green Card, both
of which are capable of generating Haskell code that uses this FFI.
</Para> </Para>
<Para> <Para>
The FFI specified in this document is not in the market of trying to Generally, the FFI consists of three parts:
completely bridge the gap between the actual type of an external <OrderedList>
function, and what is a <Emphasis>convenient</Emphasis> type for that function to the
Haskell programmer. That is the domain of tools like HaskellDirect or <ListItem>
Green Card, both of which are capable of generating Haskell code that <Para>
uses this FFI. extensions to the base language Haskell 98 (most notably <Literal>foreign
import</Literal> and <Literal>foreign export</Literal> declarations), which
are specified in the present document,
</Para>
</ListItem>
<ListItem>
<Para>
a low-level marshalling library, which is part of the
<Emphasis>Language</Emphasis> part of the <Emphasis>Haskell Extension
Library</Emphasis> (see <xref linkend="sec-???">), and a
</Para>
</ListItem>
<ListItem>
<Para>
a high-level marshalling library, which is still under development.
</Para>
</ListItem>
</OrderedList>
Before diving into the details of the language extension coming with the FFI,
let us briefly outline the two other components of the interface.
</Para>
<Para>
The low-level marshalling library consists of a portion that is independent of
the targeted foreign language and dedicated support for Haskell bindings to C
libraries (special support for other languages may be added in the future).
The language independent part is given by the module
<literal>Foreign</literal> module (see <xref linkend="sec-Foreign">). It
provides support for handling references to foreign structures, for passing
references to Haskell structures out to foreign routines, and for storing
primitive data types in raw memory blocks in a portable manner. The support
for C libraries essentially provides Haskell representations for all basic
types of C (see <xref linkend="sec-CTypes"> and <xref
linkend="sec-CTypesISO">).
</Para>
<Para>
The high-level library, of which the interface definition is not yet
finalised, provides routines for marshalling complex Haskell structures as
well as handling out and in-out parameters in a convenient, yet protable way.
</Para> </Para>
<Para> <Para>
The FFI can be split up into two complementary halves; one half that In the following, we will discuss the language extensions of the FFI (ie, the
provides Haskell constructs for importing foreign functionality into first point above). They can be split up into two complementary halves; one
Haskell, the other which lets you expose Haskell functions to the half that provides Haskell constructs for importing foreign functionality into
outside world. We start with the former, how to import external Haskell, the other which lets you expose Haskell functions to the outside
functionality into Haskell. world. We start with the former, how to import external functionality into
Haskell.
</Para> </Para>
</Sect1> </Sect1>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment