summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
14d65c3)
Change some section ids so they aren't as likely to clash with the User Guide.
+<Sect1 id="sec-ffi-intro">
<Title>Introduction
</Title>
<Title>Introduction
</Title>
-<Sect1 id="sec-primitive">
+<Sect1 id="sec-ffi-primitive">
<Title>Calling foreign functions
</Title>
<Title>Calling foreign functions
</Title>
untyped. The onus is on the programmer using <Literal>foreign import</Literal> to
ensure that the Haskell type given correctly maps on to the
type of the external function.
untyped. The onus is on the programmer using <Literal>foreign import</Literal> to
ensure that the Haskell type given correctly maps on to the
type of the external function.
-<XRef LinkEnd="sec-mapping"> specifies the mapping from
+<XRef LinkEnd="sec-ffi-mapping"> specifies the mapping from
Haskell types to external types.
</Para>
Haskell types to external types.
</Para>
-<Sect2 id="sec-prim-name">
+<Sect2 id="sec-ffi-prim-name">
<Title>Giving the external function a Haskell name
</Title>
<Title>Giving the external function a Haskell name
</Title>
-<Sect2 id="sec-prim-ext-name">
+<Sect2 id="sec-ffi-prim-ext-name">
<Title>Naming the external function
</Title>
<Title>Naming the external function
</Title>
+<Sect2 id="sec-ffi-cconv">
<Title>Calling conventions
</Title>
<Title>Calling conventions
</Title>
-<Sect2 id="sec-prim-types">
+<Sect2 id="sec-ffi-prim-types">
<Title>External function types
</Title>
<Title>External function types
</Title>
GHC permits the passing of its byte array primitive types
to external functions. There's some restrictions on when
GHC permits the passing of its byte array primitive types
to external functions. There's some restrictions on when
-they can be used; see <XRef LinkEnd="sec-arguments">
+they can be used; see <XRef LinkEnd="sec-ffi-arguments">
for more details.
</Para>
</ListItem>
for more details.
</Para>
</ListItem>
-<XRef LinkEnd="sec-results"> defines
-<Literal>prim_result</Literal>; <XRef LinkEnd="sec-arguments">
+<XRef LinkEnd="sec-ffi-results"> defines
+<Literal>prim_result</Literal>; <XRef LinkEnd="sec-ffi-arguments">
defines <Literal>prim_arg</Literal>.
</Para>
defines <Literal>prim_arg</Literal>.
</Para>
-<Sect3 id="sec-arguments">
+<Sect3 id="sec-ffi-arguments">
<Title>Argument types
</Title>
<Title>Argument types
</Title>
The <Emphasis>stable pointer</Emphasis> <Literal>StablePtr</Literal> type looks out of place in
this list of C-like types, but it has a well-defined and simple
The <Emphasis>stable pointer</Emphasis> <Literal>StablePtr</Literal> type looks out of place in
this list of C-like types, but it has a well-defined and simple
-C mapping, see <XRef LinkEnd="sec-mapping">
+C mapping, see <XRef LinkEnd="sec-ffi-mapping">
-<Sect3 id="sec-results">
+<Sect3 id="sec-ffi-results">
<Title>Result type
</Title>
<Title>Result type
</Title>
-<Sect2 id="sec-mapping">
+<Sect2 id="sec-ffi-mapping">
<Title>Type mapping
</Title>
<Title>Type mapping
</Title>
and the outside, needs to be precisely defined. We do this by
presenting a mapping to C, as it is commonly used and most other
languages define a mapping to it. Table
and the outside, needs to be precisely defined. We do this by
presenting a mapping to C, as it is commonly used and most other
languages define a mapping to it. Table
-<XRef LinkEnd="sec-mapping-table">
+<XRef LinkEnd="sec-ffi-mapping-table">
defines the mapping between Haskell and C types.
</Para>
<Para>
defines the mapping between Haskell and C types.
</Para>
<Para>
-<Table id="sec-mapping-table">
+<Table id="sec-ffi-mapping-table">
<Title>Mapping of Haskell types to C types</Title>
<TGroup Cols="4">
<Title>Mapping of Haskell types to C types</Title>
<TGroup Cols="4">
-<Sect2 id="sec-prim-remarks">
+<Sect2 id="sec-ffi-prim-remarks">
<Title>Some <Literal>foreign import</Literal> wrinkles
</Title>
<Title>Some <Literal>foreign import</Literal> wrinkles
</Title>
of being called. This will typically happen when the imported
function end up calling Haskell functions that reside in the same
'Haskell world' (i.e., shares the same storage manager heap) -- see
of being called. This will typically happen when the imported
function end up calling Haskell functions that reside in the same
'Haskell world' (i.e., shares the same storage manager heap) -- see
-<XRef LinkEnd="sec-entry"> for
+<XRef LinkEnd="sec-ffi-entry"> for
details of how the FFI let's you call Haskell functions from the outside.
If the programmer can guarantee that the imported function won't
call back into Haskell, the <Literal>foreign import</Literal> can be marked as
details of how the FFI let's you call Haskell functions from the outside.
If the programmer can guarantee that the imported function won't
call back into Haskell, the <Literal>foreign import</Literal> can be marked as
-'unsafe' (see <XRef LinkEnd="sec-primitive"> for details of
+'unsafe' (see <XRef LinkEnd="sec-ffi-primitive"> for details of
how to do this.)
Unsafe calls are cheaper than safe ones, so distinguishing the two
how to do this.)
Unsafe calls are cheaper than safe ones, so distinguishing the two
-<Sect1 id="sec-prim-dynamic">
+<Sect1 id="sec-ffi-prim-dynamic">
<Title>Invoking external functions via a pointer
</Title>
<Title>Invoking external functions via a pointer
</Title>
+<Sect1 id="sec-ffi-entry">
<Title>Exposing Haskell functions
</Title>
<Title>Exposing Haskell functions
</Title>
-<Sect2 id="sec-callback">
+<Sect2 id="sec-ffi-callback">
<Title>Exposing Haskell function values
</Title>
<Title>Exposing Haskell function values
</Title>
<Para>
where <Literal>cType[[]]</Literal> is the Haskell to C type mapping presented
<Para>
where <Literal>cType[[]]</Literal> is the Haskell to C type mapping presented
-in <XRef LinkEnd="sec-mapping">.
+in <XRef LinkEnd="sec-ffi-mapping">.
-<Sect2 id="sec-foreign-label">
+<Sect2 id="sec-ffi-foreign-label">
<Title>Code addresses
</Title>
<Title>Code addresses
</Title>
</Sect1>
<!-- This doesn't need to be seen in the docs
</Sect1>
<!-- This doesn't need to be seen in the docs
-<Sect1 id="sec-changelog">
+<Sect1 id="sec-ffi-changelog">
<Title>Change history
</Title>
<Title>Change history
</Title>
<Para>
Updated defnition of <Literal>varid</Literal> in
<Para>
Updated defnition of <Literal>varid</Literal> in
-<XRef LinkEnd="sec-prim-name"> to reflect Haskell98's.
+<XRef LinkEnd="sec-ffi-prim-name"> to reflect Haskell98's.
</Para>
</ListItem>
<ListItem>
</Para>
</ListItem>
<ListItem>