[project @ 2000-06-07 16:15:22 by rrt]
[ghc-hetmet.git] / docs / ffi.sgml
1 <!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN"> 
2
3 <Article id="ffi">
4
5 <ArtHeader>
6
7 <Title>A Haskell foreign function interface</Title>
8 <Author><OtherName>The GHC Team</OtherName></Author>
9 <Address><Email>glasgow-haskell-&lcub;users,bugs&rcub;@dcs.gla.ac.uk</Email>
10 </Address>
11 <Edition>version 0.99</Edition>
12 <PubDate>May 2000</PubDate>
13
14 </ArtHeader>
15
16 <Sect1 id="sec-intro">
17 <Title>Introduction
18 </Title>
19
20 <Para>
21 The motivation behind this foreign function interface(FFI)
22 specification is to make it possible to describe in Haskell <Emphasis>source
23 code</Emphasis> the interface to foreign functionality in a Haskell system
24 independent manner. It builds on experiences made with the previous
25 foreign function interfaces provided by GHC and Hugs.
26 </Para>
27
28 <Para>
29 The FFI specified in this document is not in the market of trying to
30 completely bridge the gap between the actual type of an external
31 function, and what is a <Emphasis>convenient</Emphasis> type for that function to the
32 Haskell programmer. That is the domain of tools like HaskellDirect or
33 Green Card, both of which are capable of generating Haskell code that
34 uses this FFI.
35 </Para>
36
37 <Para>
38 The FFI can be split up into two complementary halves; one half that
39 provides Haskell constructs for importing foreign functionality into
40 Haskell, the other which lets you expose Haskell functions to the
41 outside world. We start with the former, how to import external
42 functionality into Haskell.
43 </Para>
44
45 </Sect1>
46
47 <Sect1 id="sec-primitive">
48 <Title>Calling foreign functions
49 </Title>
50
51 <Para>
52 To bind a Haskell variable name and type to an external function, we
53 introduce a new construct: <Literal>foreign import</Literal>. It defines the type of a Haskell function together with the name of an external function that actually implements it. The syntax of <Literal>foreign import</Literal> construct is as follows:
54 </Para>
55
56 <Para>
57
58 <ProgramListing>
59 topdecl 
60   : ...
61   ..
62   | 'foreign' 'import' [callconv] [ext_fun] ['unsafe'] varid '::' prim_type
63 </ProgramListing>
64
65 </Para>
66
67 <Para>
68 A <Literal>foreign import</Literal> declaration is only allowed as a toplevel
69 declaration. It consists of two parts, one giving the Haskell type
70 (<Literal>prim&lowbar;type</Literal>), Haskell name (<Literal>varid</Literal>) and a flag indicating whether the
71 primitive is unsafe, the other giving details of the name of the
72 external function (<Literal>ext&lowbar;fun</Literal>) and its calling interface
73 (<Literal>callconv</Literal>.)
74 </Para>
75
76 <Para>
77 Giving a Haskell name and type to an external entry point is clearly
78 an unsafe thing to do, as the external name will in most cases be
79 untyped. The onus is on the programmer using <Literal>foreign import</Literal> to
80 ensure that the Haskell type given correctly maps on to the
81 type of the external function. Section
82 <XRef LinkEnd="sec-mapping"> specifies the mapping from 
83 Haskell types to external types.
84 </Para>
85
86 <Sect2 id="sec-prim-name">
87 <Title>Giving the external function a Haskell name
88 </Title>
89
90 <Para>
91 The external function has to be given a Haskell name. The name
92 must be a Haskell <Literal>varid</Literal>, so the language rules regarding
93 variable names must be followed, i.e., it must start with a
94 lower case letter followed by a sequence of alphanumeric
95 (`in the Unicode sense') characters or '.
96
97 <Footnote>
98 <Para>
99 Notice that with Haskell 98, underscore ('&lowbar;') is included in
100 the character class <Literal>small</Literal>.
101 </Para>
102 </Footnote>
103
104 </Para>
105
106 <Para>
107 <ProgramListing>
108 varid : small ( small | large | udigit | ' )*
109 </ProgramListing>
110 </Para>
111
112 </Sect2>
113
114 <Sect2 id="sec-prim-ext-name">
115 <Title>Naming the external function
116 </Title>
117
118 <Para>
119 The name of the external function consists of two parts,
120 one specifying its location, the other its name:
121 </Para>
122
123 <Para>
124
125 <ProgramListing>
126 ext_fun  : ext_loc ext_name
127          | ext_name
128
129 ext_name : string
130 ext_loc  : string
131 </ProgramListing>
132
133 </Para>
134
135 <Para>
136 For example,
137 </Para>
138
139 <Para>
140
141 <ProgramListing>
142 foreign import stdcall "Advapi32" "RegCloseKey" regCloseKey :: Addr -&#62; IO ()
143 </ProgramListing>
144
145 </Para>
146
147 <Para>
148 states that the external function named <Function>RegCloseKey</Function> at location
149 <Function>Advapi32</Function> should be bound to the Haskell name <Function>regCloseKey</Function>.
150 For a Win32 Haskell implementation that supports the loading of DLLs
151 on-the-fly, this declaration will most likely cause the run-time
152 system to load the <Filename>Advapi32.dll</Filename> DLL before looking up the 
153 function <Function>RegCloseKey()</Function> therein to get at the function pointer
154 to use when invoking <Function>regCloseKey</Function>. 
155 </Para>
156
157 <Para>
158 Compiled implementations may do something completely different, i.e.,
159 mangle "RegCloseKey" to convert it into an archive/import library
160 symbol, that's assumed to be in scope when linking. The details of
161 which are platform (and compiler command-line) dependent.
162 </Para>
163
164 <Para>
165 If the location part is left out, the name of the external function
166 specifies a symbol that is assumed to be in scope when linking.
167 </Para>
168
169 <Para>
170 The location part can either contain an absolute `address' (i.e.,
171 path) of the archive/DLL, or just its name, leaving it up to the
172 underlying system (system meaning both RTS/compiler and OS) to resolve
173 the name to its real location.
174 </Para>
175
176 <Para>
177 An implementation is <Emphasis>expected</Emphasis> to be able to intelligently
178 transform the <Literal>ext&lowbar;loc</Literal> location to fit platform-specific
179 practices for naming dynamic libraries. For instance, given the
180 declaration
181 </Para>
182
183 <Para>
184
185 <ProgramListing>
186 foreign import "Foo" "foo" foo :: Int -&#62; Int -&#62; IO ()
187 </ProgramListing>
188
189 </Para>
190
191 <Para>
192 an implementation should map <Filename>Foo</Filename> to <Filename>"Foo.dll"</Filename> on a Win32
193 platform, and <Filename>libFoo.so</Filename> on ELF platforms. If the lookup of the
194 dynamic library with this transformed location name should fail, the
195 implementation should then attempt to use the original name before
196 eventually giving up. As part of their documentation, implementations
197 of <Literal>foreign import</Literal> should specify the exact details of how
198 <Literal>ext&lowbar;loc</Literal>s are transformed and resolved, including the list of
199 directories searched (and the order in which they are.)
200 </Para>
201
202 <Para>
203 In the case the Haskell name of the imported function is identical to
204 the external name, the <Literal>ext&lowbar;fun</Literal> can be omitted. i.e.,
205 </Para>
206
207 <Para>
208
209 <ProgramListing>
210 foreign import sin :: Double -&#62; IO Double
211 </ProgramListing>
212
213 </Para>
214
215 <Para>
216 is identical to 
217 </Para>
218
219 <Para>
220
221 <ProgramListing>
222 foreign import "sin" sin :: Double -&#62; IO Double
223 </ProgramListing>
224
225 </Para>
226
227 </Sect2>
228
229 <Sect2 id="sec-cconv">
230 <Title>Calling conventions
231 </Title>
232
233 <Para>
234 The number of calling conventions supported is fixed:
235 </Para>
236
237 <Para>
238
239 <ProgramListing>
240 callconv : ccall | stdcall
241 </ProgramListing>
242
243 </Para>
244
245 <Para>
246 <VariableList>
247
248 <VarListEntry>
249 <Term><Literal>ccall</Literal></Term>
250 <ListItem>
251 <Para>
252 The 'default' calling convention on a platform, i.e., the one
253 used to do (C) function calls.
254 </Para>
255
256 <Para>
257 In the case of x86 platforms, the caller pushes function arguments
258 from right to left on the C stack before calling. The caller is
259 responsible for popping the arguments off of the C stack on return.
260 </Para>
261 </ListItem>
262 </VarListEntry>
263 <VarListEntry>
264 <Term><Literal>stdcall</Literal></Term>
265 <ListItem>
266 <Para>
267 A Win32 specific calling convention. The same as <Literal>ccall</Literal>, except
268 that the callee cleans up the C stack before returning.
269
270 <Footnote>
271 <Para>
272 The <Literal>stdcall</Literal> is a Microsoft Win32 specific wrinkle; it used
273 throughout the Win32 API, for instance. On platforms where
274 <Literal>stdcall</Literal> isn't meaningful, it should be treated as being equal
275 to <Literal>ccall</Literal>.
276 </Para>
277 </Footnote>
278
279 </Para>
280 </ListItem>
281 </VarListEntry>
282 </VariableList>
283 </Para>
284
285 <Para>
286 <Emphasis remap="bf">Some remarks:</Emphasis>
287
288 <ItemizedList>
289 <ListItem>
290
291 <Para>
292 Interoperating well with external code is the name of the game here,
293 so the guiding principle when deciding on what calling conventions
294 to include in <Literal>callconv</Literal> is that there's a demonstrated need for
295 a particular calling convention. Should it emerge that the inclusion
296 of other calling conventions will generally improve the quality of
297 this Haskell FFI, they will be considered for future inclusion in
298 <Literal>callconv</Literal>.
299 </Para>
300 </ListItem>
301 <ListItem>
302
303 <Para>
304 Supporting <Literal>stdcall</Literal> (and perhaps other platform-specific calling
305 conventions) raises the issue of whether a Haskell FFI should allow
306 the user to write platform-specific Haskell code. The calling
307 convention is clearly an integral part of an external function's
308 interface, so if the one used differs from the standard one specified
309 by the platform's ABI <Emphasis>and</Emphasis> that convention is used by a
310 non-trivial amount of external functions, the view of the FFI authors
311 is that a Haskell FFI should support it.
312 </Para>
313 </ListItem>
314 <ListItem>
315
316 <Para>
317 For <Literal>foreign import</Literal> (and other <Literal>foreign</Literal> declarations),
318 supplying the calling convention is optional. If it isn't supplied,
319 it is treated as if <Literal>ccall</Literal> was specified. Users are encouraged
320 to leave out the specification of the calling convention, if possible.
321 </Para>
322 </ListItem>
323
324 </ItemizedList>
325
326 </Para>
327
328 </Sect2>
329
330 <Sect2 id="sec-prim-types">
331 <Title>External function types
332 </Title>
333
334 <Para>
335 The range of types that can be passed as arguments to an external
336 function is restricted (as are the range of results coming back):
337 </Para>
338
339 <Para>
340
341 <ProgramListing>
342 prim_type : IO prim_result
343           | prim_result
344           | prim_arg '-&#62;' prim_type
345 </ProgramListing>
346
347 </Para>
348
349 <Para>
350
351 <ItemizedList>
352 <ListItem>
353
354 <Para>
355 If you associate a non-IO type with an external function, you
356 have the same 'proof obligations' as when you make use of
357 <Function>IOExts.unsafePerformIO</Function> in your Haskell programs.
358 </Para>
359 </ListItem>
360 <ListItem>
361
362 <Para>
363 The external function is strict in all its arguments.
364 </Para>
365 </ListItem>
366 <ListItem>
367
368 <Para>
369 <Emphasis>GHC only:</Emphasis> The GHC FFI implementation provides one extension
370 to <Literal>prim&lowbar;type</Literal>:
371
372
373 <ProgramListing>
374 prim_type : ... 
375           | unsafe_arr_ty '-&#62;' prim_type
376
377 unsafe_arr_ty : ByteArray a
378               | MutableByteArray i s a
379 </ProgramListing>
380
381
382 GHC permits the passing of its byte array primitive types
383 to external functions. There's some restrictions on when
384 they can be used; see Section <XRef LinkEnd="sec-arguments">
385 for more details.
386 </Para>
387 </ListItem>
388
389 </ItemizedList>
390
391 </Para>
392
393 <Para>
394 Section <XRef LinkEnd="sec-results"> defines
395 <Literal>prim&lowbar;result</Literal>; Section <XRef LinkEnd="sec-arguments">
396 defines <Literal>prim&lowbar;arg</Literal>.
397 </Para>
398
399 <Sect3 id="sec-arguments">
400 <Title>Argument types
401 </Title>
402
403 <Para>
404 The external function expects zero or more arguments. The set of legal
405 argument types is restricted to the following set:
406 </Para>
407
408 <Para>
409
410 <ProgramListing>
411 prim_arg : ext_ty | new_ty | ForeignObj
412
413 new_ty : a Haskell newtype of a prim_arg.
414
415 ext_ty : int_ty   | word_ty | float_ty
416        | Addr     | Char    | StablePtr a
417        | Bool
418
419 int_ty       : Int   | Int8   | Int16   | Int32 | Int64
420 word_ty      : Word8 | Word16 | Word32  | Word64
421 float_ty     : Float | Double
422 </ProgramListing>
423
424 </Para>
425
426 <Para>
427
428 <ItemizedList>
429 <ListItem>
430
431 <Para>
432 <Literal>ext&lowbar;ty</Literal> represent the set of basic types supported by
433 C-like languages, although the numeric types are explicitly sized.
434
435 The <Emphasis>stable pointer</Emphasis> <Literal>StablePtr</Literal> type looks out of place in
436 this list of C-like types, but it has a well-defined and simple
437 C mapping, see Section <XRef LinkEnd="sec-mapping">
438 for details.
439
440 </Para>
441 </ListItem>
442 <ListItem>
443
444 <Para>
445 <Literal>prim&lowbar;arg</Literal> represent the set of permissible argument types. In
446 addition to <Literal>ext&lowbar;ty</Literal>, <Literal>ForeignObj</Literal> is also included.
447
448 The <Literal>ForeignObj</Literal> type represent values that are pointers to some
449 external entity/object. It differs from the <Literal>Addr</Literal> type in that
450 <Literal>ForeignObj</Literal>s are <Emphasis>finalized</Emphasis>, i.e., once the garbage collector
451 determines that a <Literal>ForeignObj</Literal> is unreachable, it will invoke a
452 finalising procedure attached to the <Literal>ForeignObj</Literal> to notify the
453 outside world that we're through with using it.
454
455 </Para>
456 </ListItem>
457 <ListItem>
458
459 <Para>
460 Haskell <Literal>newtype</Literal>s that wrap up a <Literal>prim&lowbar;arg</Literal> type can also
461 be passed to external functions. 
462 </Para>
463 </ListItem>
464 <ListItem>
465
466 <Para>
467 Haskell type synonyms for any of the above can also be used
468 in <Literal>foreign import</Literal> declarations. Qualified names likewise,
469 i.e. <Literal>Word.Word32</Literal> is legal.
470
471 </Para>
472 </ListItem>
473 <ListItem>
474
475 <Para>
476 <Literal>foreign import</Literal> does not support the binding to external
477 constants/variables. A <Literal>foreign import</Literal> declaration that takes no
478 arguments represent a binding to a function with no arguments.
479 </Para>
480 </ListItem>
481 <ListItem>
482
483 <Para>
484 <Emphasis>GHC only:</Emphasis> GHC's implementation of the FFI provides
485 two extensions:
486
487 <ItemizedList>
488 <ListItem>
489
490 <Para>
491 Support for passing heap allocated byte arrays to an external
492 function
493
494 <ProgramListing>
495 prim_type : ... 
496           | prim_arg '-&#62;' prim_type
497           | unsafe_arr_ty '-&#62;' prim_type
498
499 unsafe_arr_ty : ByteArray a
500               | MutableByteArray i s a
501 </ProgramListing>
502
503
504 GHC's <Literal>ByteArray</Literal> and <Literal>MutableByteArray</Literal> primitive types are
505 (im)mutable chunks of memory allocated on the Haskell heap, and
506 pointers to these can be passed to <Literal>foreign import</Literal>ed external
507 functions provided they are marked as <Literal>unsafe</Literal>. Since it is
508 inherently unsafe to hand out references to objects in the Haskell
509 heap if the external call may cause a garbage collection to happen,
510 you have to annotate the <Literal>foreign import</Literal> declaration with
511 the attribute <Literal>unsafe</Literal>. By doing so, the user explicitly states
512 that the external function won't provoke a garbage collection,
513 so passing out heap references to the external function is allright.
514
515 </Para>
516 </ListItem>
517 <ListItem>
518
519 <Para>
520 Another GHC extension is the support for unboxed types:
521
522
523 <ProgramListing>
524 prim_arg : ...  | unboxed_h_ty
525 ext_ty   : .... | unboxed_ext_ty
526
527 unboxed_ext_ty : Int#   | Word#    | Char#
528                | Float# | Double#  | Addr# 
529                | StablePtr# a
530 unboxed_h_ty : MutableByteArray# | ForeignObj#
531              | ByteArray#
532 </ProgramListing>
533
534
535 Clearly, if you want to be portable across Haskell systems, using 
536 system-specific extensions such as this is not advisable; avoid
537 using them if you can. (Support for using unboxed types might
538 be withdrawn sometime in the future.)
539 </Para>
540 </ListItem>
541
542 </ItemizedList>
543
544 </Para>
545 </ListItem>
546
547 </ItemizedList>
548
549 </Para>
550
551 </Sect3>
552
553 <Sect3 id="sec-results">
554 <Title>Result type
555 </Title>
556
557 <Para>
558 An external function is permitted to return the following
559 range of types:
560 </Para>
561
562 <Para>
563
564 <ProgramListing>
565 prim_result : ext_ty | new_ext_ty | ()
566
567 new_ext_ty : a Haskell newtype of an ext_ty.
568 </ProgramListing>
569
570 </Para>
571
572 <Para>
573 where <Literal>()</Literal> represents <Literal>void</Literal> / no result. 
574 </Para>
575
576 <Para>
577
578 <ItemizedList>
579 <ListItem>
580
581 <Para>
582 External functions cannot raise exceptions (IO exceptions or non-IO ones.)
583 It is the responsibility of the <Literal>foreign import</Literal> user to layer
584 any error handling on top of an external function.
585 </Para>
586 </ListItem>
587 <ListItem>
588
589 <Para>
590 Only external types (<Literal>ext&lowbar;ty</Literal>) can be passed back, i.e., returning
591 <Literal>ForeignObj</Literal>s is not supported/allowed. 
592 </Para>
593 </ListItem>
594 <ListItem>
595
596 <Para>
597 Haskell newtypes that wrap up <Literal>ext&lowbar;ty</Literal> are also permitted.
598 </Para>
599 </ListItem>
600
601 </ItemizedList>
602
603 </Para>
604
605 </Sect3>
606
607 </Sect2>
608
609 <Sect2 id="sec-mapping">
610 <Title>Type mapping
611 </Title>
612
613 <Para>
614 For the FFI to be of any practical use, the properties and sizes of
615 the various types that can be communicated between the Haskell world
616 and the outside, needs to be precisely defined. We do this by
617 presenting a mapping to C, as it is commonly used and most other
618 languages define a mapping to it. Table
619 <XRef LinkEnd="sec-mapping-table">
620 defines the mapping between Haskell and C types.
621 </Para>
622
623 <Para>
624
625 <Table id="sec-mapping-table">
626 <Title>Mapping of Haskell types to C types</Title>
627
628 <TGroup Cols="6">
629 <ColSpec Align="Left" Colsep="0">
630 <ColSpec Align="Left" Colsep="0">
631 <ColSpec Align="Left" Colsep="0">
632 <ColSpec Align="Left" Colsep="0">
633 <ColSpec Align="Left" Colsep="0">
634 <ColSpec Align="Left" Colsep="0">
635 <TBody>
636 <Row RowSep="1">
637 <Entry>Haskell type </Entry>
638 <Entry> C type </Entry>
639 <Entry> requirement </Entry>
640 <Entry> range (9) </Entry>
641 <Entry> </Entry>
642 <Entry> </Entry>
643 </Row>
644 <Row>
645 <Entry>
646 <Literal>Char</Literal> </Entry>
647 <Entry> <Literal>HsChar</Literal> </Entry>
648 <Entry> unspec. integral type </Entry>
649 <Entry> <Literal>HS&lowbar;CHAR&lowbar;MIN</Literal> </Entry>
650 <Entry>..</Entry>
651 <Entry> <Literal>HS&lowbar;CHAR&lowbar;MAX</Literal></Entry>
652 </Row>
653 <Row>
654 <Entry>
655 <Literal>Int</Literal> </Entry>
656 <Entry> <Literal>HsInt</Literal> </Entry>
657 <Entry> signed integral of unspec. size(4) </Entry>
658 <Entry> <Literal>HS&lowbar;INT&lowbar;MIN</Literal> </Entry>
659 <Entry>..</Entry>
660 <Entry> <Literal>HS&lowbar;INT&lowbar;MAX</Literal></Entry>
661 </Row>
662 <Row>
663 <Entry>
664 <Literal>Int8</Literal> (2) </Entry>
665 <Entry> <Literal>HsInt8</Literal> </Entry>
666 <Entry> 8 bit signed integral </Entry>
667 <Entry> <Literal>HS&lowbar;INT8&lowbar;MIN</Literal> </Entry>
668 <Entry>..</Entry>
669 <Entry> <Literal>HS&lowbar;INT8&lowbar;MAX</Literal></Entry>
670 </Row>
671 <Row>
672 <Entry>
673 <Literal>Int16</Literal> (2) </Entry>
674 <Entry> <Literal>HsInt16</Literal> </Entry>
675 <Entry> 16 bit signed integral </Entry>
676 <Entry> <Literal>HS&lowbar;INT16&lowbar;MIN</Literal> </Entry>
677 <Entry>..</Entry>
678 <Entry> <Literal>HS&lowbar;INT16&lowbar;MAX</Literal></Entry>
679 </Row>
680 <Row>
681 <Entry>
682 <Literal>Int32</Literal> (2) </Entry>
683 <Entry> <Literal>HsInt32</Literal> </Entry>
684 <Entry> 32 bit signed integral </Entry>
685 <Entry> <Literal>HS&lowbar;INT32&lowbar;MIN</Literal> </Entry>
686 <Entry>..</Entry>
687 <Entry> <Literal>HS&lowbar;INT32&lowbar;MAX</Literal></Entry>
688 </Row>
689 <Row>
690 <Entry>
691 <Literal>Int64</Literal> (2,3) </Entry>
692 <Entry> <Literal>HsInt64</Literal> </Entry>
693 <Entry> 64 bit signed integral (3) </Entry>
694 <Entry> <Literal>HS&lowbar;INT64&lowbar;MIN</Literal> </Entry>
695 <Entry>..</Entry>
696 <Entry> <Literal>HS&lowbar;INT64&lowbar;MAX</Literal></Entry>
697 </Row>
698 <Row>
699 <Entry>
700 <Literal>Word8</Literal> (2) </Entry>
701 <Entry> <Literal>HsWord8</Literal> </Entry>
702 <Entry> 8 bit unsigned integral </Entry>
703 <Entry> <Literal>0</Literal> </Entry>
704 <Entry>..</Entry>
705 <Entry> <Literal>HS&lowbar;WORD8&lowbar;MAX</Literal></Entry>
706 </Row>
707 <Row>
708 <Entry>
709 <Literal>Word16</Literal> (2) </Entry>
710 <Entry> <Literal>HsWord16</Literal> </Entry>
711 <Entry> 16 bit unsigned integral </Entry>
712 <Entry> <Literal>0</Literal> </Entry>
713 <Entry>..</Entry>
714 <Entry> <Literal>HS&lowbar;WORD16&lowbar;MAX</Literal></Entry>
715 </Row>
716 <Row>
717 <Entry>
718 <Literal>Word32</Literal> (2) </Entry>
719 <Entry> <Literal>HsWord32</Literal> </Entry>
720 <Entry> 32 bit unsigned integral </Entry>
721 <Entry> <Literal>0</Literal> </Entry>
722 <Entry>..</Entry>
723 <Entry> <Literal>HS&lowbar;WORD32&lowbar;MAX</Literal></Entry>
724 </Row>
725 <Row>
726 <Entry>
727 <Literal>Word64</Literal> (2,3) </Entry>
728 <Entry> <Literal>HsWord64</Literal> </Entry>
729 <Entry> 64 bit unsigned integral (3) </Entry>
730 <Entry> <Literal>0</Literal> </Entry>
731 <Entry>..</Entry>
732 <Entry> <Literal>HS&lowbar;WORD64&lowbar;MAX</Literal></Entry>
733 </Row>
734 <Row>
735 <Entry>
736 <Literal>Float</Literal> </Entry>
737 <Entry> <Literal>HsFloat</Literal> </Entry>
738 <Entry> floating point of unspec. size (5) </Entry>
739 <Entry> (10) </Entry>
740 <Entry> </Entry>
741 <Entry> </Entry>
742 </Row>
743 <Row>
744 <Entry>
745 <Literal>Double</Literal> </Entry>
746 <Entry> <Literal>HsDouble</Literal> </Entry>
747 <Entry> floating point of unspec. size (5) </Entry>
748 <Entry> (10) </Entry>
749 <Entry> </Entry>
750 <Entry> </Entry>
751 </Row>
752 <Row>
753 <Entry>
754 <Literal>Bool</Literal> </Entry>
755 <Entry> <Literal>HsBool</Literal> </Entry>
756 <Entry> unspec. integral type </Entry>
757 <Entry> (11) </Entry>
758 <Entry> </Entry>
759 <Entry> </Entry>
760 </Row>
761 <Row>
762 <Entry>
763 <Literal>Addr</Literal> </Entry>
764 <Entry> <Literal>HsAddr</Literal> </Entry>
765 <Entry> void* (6) </Entry>
766 <Entry> </Entry>
767 <Entry> </Entry>
768 <Entry> </Entry>
769 </Row>
770 <Row>
771 <Entry>
772 <Literal>ForeignObj</Literal> </Entry>
773 <Entry> <Literal>HsForeignObj</Literal> </Entry>
774 <Entry> void* (7) </Entry>
775 <Entry> </Entry>
776 <Entry> </Entry>
777 <Entry> </Entry>
778 </Row>
779 <Row>
780 <Entry>
781 <Literal>StablePtr</Literal> </Entry>
782 <Entry> <Literal>HsStablePtr</Literal> </Entry>
783 <Entry> void* (8) </Entry>
784 <Entry> </Entry>
785 <Entry> </Entry>
786 <Entry> </Entry>
787 </Row>
788 <Row>
789 <Entry>
790 </Entry>
791 </Row>
792 </TBody>
793
794 </TGroup>
795
796 </Table>
797
798 </Para>
799
800 <Para>
801 <Emphasis remap="bf">Some remarks:</Emphasis>
802
803 <OrderedList>
804 <ListItem>
805
806 <Para>
807 A Haskell system that implements the FFI will supply a header file
808 <Filename>HsFFI.h</Filename> that includes target platform specific definitions
809 for the above types and values.
810 </Para>
811 </ListItem>
812 <ListItem>
813
814 <Para>
815 The sized numeric types <Literal>Hs&lcub;Int,Word&rcub;&lcub;8,16,32,64&rcub;</Literal> have
816 a 1-1 mapping to ISO C 99's <Literal>&lcub;,u&rcub;int&lcub;8,16,32,64&rcub;&lowbar;t</Literal>. For systems
817 that doesn't support this revision of ISO C, a best-fit mapping
818 onto the supported C types is provided.
819 </Para>
820 </ListItem>
821 <ListItem>
822
823 <Para>
824 An implementation which does not support 64 bit integral types
825 on the C side should implement <Literal>Hs&lcub;Int,Word&rcub;64</Literal> as a struct. In
826 this case the bounds <Constant>HS&lowbar;INT64&lowbar;&lcub;MIN,MAX&rcub;</Constant> and <Constant>HS&lowbar;WORD64&lowbar;MAX</Constant>
827 are undefined.
828 </Para>
829 </ListItem>
830 <ListItem>
831
832 <Para>
833 A valid Haskell representation of <Literal>Int</Literal> has to be equal to or
834 wider than 30 bits. The <Literal>HsInt</Literal> synonym is guaranteed to map
835 onto a C type that satisifies Haskell's requirement for <Literal>Int</Literal>.
836 </Para>
837 </ListItem>
838 <ListItem>
839
840 <Para>
841 It is guaranteed that <Literal>Hs&lcub;Float,Double&rcub;</Literal> are one of C's
842 floating-point types <Literal>float</Literal>/<Literal>double</Literal>/<Literal>long double</Literal>.
843 </Para>
844 </ListItem>
845 <ListItem>
846
847 <Para>
848 It is guaranteed that <Literal>HsAddr</Literal> is of the same size as <Literal>void*</Literal>, so
849 any other pointer type can be converted to and from HsAddr without any
850 loss of information (K&amp;R, Appendix A6.8).
851 </Para>
852 </ListItem>
853 <ListItem>
854
855 <Para>
856 Foreign objects are handled like <Literal>Addr</Literal> by the FFI, so there
857 is again the guarantee that <Literal>HsForeignObj</Literal> is the same as
858 <Literal>void*</Literal>. The separate name is meant as a reminder that there is
859 a finalizer attached to the object pointed to.
860 </Para>
861 </ListItem>
862 <ListItem>
863
864 <Para>
865 Stable pointers are passed as addresses by the FFI, but this is
866 only because a <Literal>void*</Literal> is used as a generic container in most
867 APIs, not because they are real addresses. To make this special
868 case clear, a separate C type is used here. 
869 </Para>
870 </ListItem>
871 <ListItem>
872
873 <Para>
874 The bounds are preprocessor macros, so they can be used in
875 <Literal>&num;if</Literal> and for array bounds.
876 </Para>
877 </ListItem>
878 <ListItem>
879
880 <Para>
881 Floating-point limits are a little bit more complicated, so
882 preprocessor macros mirroring ISO C's <Filename>float.h</Filename> are provided:
883
884 <ProgramListing>
885 HS_{FLOAT,DOUBLE}_RADIX
886 HS_{FLOAT,DOUBLE}_ROUNDS
887 HS_{FLOAT,DOUBLE}_EPSILON
888 HS_{FLOAT,DOUBLE}_DIG
889 HS_{FLOAT,DOUBLE}_MANT_DIG
890 HS_{FLOAT,DOUBLE}_MIN
891 HS_{FLOAT,DOUBLE}_MIN_EXP
892 HS_{FLOAT,DOUBLE}_MIN_10_EXP
893 HS_{FLOAT,DOUBLE}_MAX
894 HS_{FLOAT,DOUBLE}_MAX_EXP
895 HS_{FLOAT,DOUBLE}_MAX_10_EXP
896 </ProgramListing>
897
898 </Para>
899 </ListItem>
900 <ListItem>
901
902 <Para>
903 It is guaranteed that Haskell's <Literal>False</Literal>/<Literal>True</Literal> map to
904 C's <Literal>0</Literal>/<Literal>1</Literal>, respectively, and vice versa. The mapping of
905 any other integral value to <Literal>Bool</Literal> is left unspecified.
906 </Para>
907 </ListItem>
908 <ListItem>
909
910 <Para>
911 To avoid name clashes, identifiers starting with <Literal>Hs</Literal> and
912 macros starting with <Literal>HS&lowbar;</Literal> are reserved for the FFI.
913 </Para>
914 </ListItem>
915 <ListItem>
916
917 <Para>
918 <Emphasis>GHC only:</Emphasis> The GHC specific types <Literal>ByteArray</Literal> and
919 <Literal>MutableByteArray</Literal> both map to <Literal>char*</Literal>.
920 </Para>
921 </ListItem>
922
923 </OrderedList>
924
925 </Para>
926
927 </Sect2>
928
929 <Sect2 id="sec-prim-remarks">
930 <Title>Some <Literal>foreign import</Literal> wrinkles
931 </Title>
932
933 <Para>
934
935 <ItemizedList>
936 <ListItem>
937
938 <Para>
939 By default, a <Literal>foreign import</Literal> function is <Emphasis>safe</Emphasis>. A safe
940 external function may cause a Haskell garbage collection as a result
941 of being called. This will typically happen when the imported
942 function end up calling Haskell functions that reside in the same
943 'Haskell world' (i.e., shares the same storage manager heap) -- see
944 Section <XRef LinkEnd="sec-entry"> for
945 details of how the FFI let's you call Haskell functions from the outside.
946
947 If the programmer can guarantee that the imported function won't
948 call back into Haskell, the <Literal>foreign import</Literal> can be marked as
949 'unsafe' (see Section <XRef LinkEnd="sec-primitive"> for details of
950 how to do this.)
951
952 Unsafe calls are cheaper than safe ones, so distinguishing the two
953 classes of external calls may be worth your while if you're extra
954 conscious about performance.
955
956 </Para>
957 </ListItem>
958 <ListItem>
959
960 <Para>
961 A <Literal>foreign import</Literal>ed function should clearly not need to know that
962 it is being called from Haskell. One consequence of this is that the
963 lifetimes of the arguments that are passed from Haskell <Emphasis>must</Emphasis>
964 equal that of a normal C call. For instance, for the following decl,
965
966
967 <ProgramListing>
968 foreign import "mumble" mumble :: ForeignObj -&#62; IO ()
969
970 f :: Addr -&#62; IO ()
971 f ptr = do
972   fo &#60;- makeForeignObj ptr myFinalizer
973   mumble fo
974 </ProgramListing>
975
976
977 The <Literal>ForeignObj</Literal> must live across the call to <Function>mumble</Function> even if
978 it is not subsequently used/reachable. Why the insistence on this?
979 Consider what happens if <Function>mumble</Function> calls a function which calls back
980 into the Haskell world to execute a function, behind our back as it
981 were. This evaluation may possibly cause a garbage collection, with
982 the result that <Literal>fo</Literal> may end up being finalised.
983
984 By guaranteeing that <Literal>fo</Literal> will be considered live across the call
985 to <Function>mumble</Function>, the unfortunate situation where <Literal>fo</Literal> is finalised
986 (and hence the reference passed to <Function>mumble</Function> is suddenly no longer
987 valid) is avoided.
988
989
990 </Para>
991 </ListItem>
992
993 </ItemizedList>
994
995 </Para>
996
997 </Sect2>
998
999 </Sect1>
1000
1001 <Sect1 id="sec-prim-dynamic">
1002 <Title>Invoking external functions via a pointer
1003 </Title>
1004
1005 <Para>
1006 A <Literal>foreign import</Literal> declaration imports an external 
1007 function into Haskell. (The name of the external function
1008 is statically known, but the loading/linking of it may very well
1009 be delayed until run-time.) A <Literal>foreign import</Literal> declaration is then
1010 (approximately) just a type cast of an external function with a
1011 <Emphasis>statically known name</Emphasis>. 
1012 </Para>
1013
1014 <Para>
1015 An extension of <Literal>foreign import</Literal> is the support for <Emphasis>dynamic</Emphasis> type
1016 casts of external names/addresses:
1017 </Para>
1018
1019 <Para>
1020
1021 <ProgramListing>
1022 topdecl 
1023    : ...
1024    ..
1025    | 'foreign' 'import' [callconv] 'dynamic' ['unsafe']
1026             varid :: Addr -&#62; (prim_args -&#62; IO prim_result)
1027 </ProgramListing>
1028
1029 </Para>
1030
1031 <Para>
1032 i.e., identical to a <Literal>foreign import</Literal> declaration, but for the
1033 specification of <Literal>dynamic</Literal> instead of the name of an external
1034 function. The presence of <Literal>dynamic</Literal> indicates that when an
1035 application of <Literal>varid</Literal> is evaluated, the function pointed to by its
1036 first argument will be invoked, passing it the rest of <Literal>varid</Literal>'s
1037 arguments.
1038 </Para>
1039
1040 <Para>
1041 What are the uses of this? Native invocation of COM methods,
1042 <Footnote>
1043 <Para>
1044 Or the interfacing to any other software component technologies.
1045 </Para>
1046 </Footnote>
1047 Haskell libraries that want to be dressed up as C libs (and hence may have
1048 to support C callbacks), Haskell code that need to dynamically load
1049 and execute code.
1050 </Para>
1051
1052 </Sect1>
1053
1054 <Sect1 id="sec-entry">
1055 <Title>Exposing Haskell functions
1056 </Title>
1057
1058 <Para>
1059 So far we've provided the Haskell programmer with ways of importing
1060 external functions into the Haskell world. The other half of the FFI
1061 coin is how to expose Haskell functionality to the outside world. So,
1062 dual to the <Literal>foreign import</Literal> declaration is <Literal>foreign export</Literal>:
1063 </Para>
1064
1065 <Para>
1066
1067 <ProgramListing>
1068 topdecl 
1069   : ...
1070   ..
1071   | 'foreign' 'export' callconv [ext_name] varid :: prim_type
1072 </ProgramListing>
1073
1074 </Para>
1075
1076 <Para>
1077 A <Literal>foreign export</Literal> declaration tells the compiler to expose a
1078 locally defined Haskell function to the outside world, i.e., wrap
1079 it up behind a calling interface that's useable from C. It is only
1080 permitted at the toplevel, where you have to specify the type at
1081 which you want to export the function, along with the calling
1082 convention to use. For instance, the following export declaration:
1083 </Para>
1084
1085 <Para>
1086
1087 <ProgramListing>
1088 foreign export ccall "foo" bar :: Int -&#62; Addr -&#62; IO Double
1089 </ProgramListing>
1090
1091 </Para>
1092
1093 <Para>
1094 will cause a Haskell system to generate the following C callable
1095 function:
1096 </Para>
1097
1098 <Para>
1099
1100 <ProgramListing>
1101 HsDouble foo(HsInt arg1, HsAddr arg2);
1102 </ProgramListing>
1103
1104 </Para>
1105
1106 <Para>
1107 When invoked, it will call the Haskell function <Function>bar</Function>, passing
1108 it the two arguments that was passed to <Function>foo()</Function>. 
1109 </Para>
1110
1111 <Para>
1112
1113 <ItemizedList>
1114 <ListItem>
1115
1116 <Para>
1117 The range of types that can be passed as arguments and results
1118 is restricted, since <Literal>varid</Literal> has got a <Literal>prim&lowbar;type</Literal>.
1119 </Para>
1120 </ListItem>
1121 <ListItem>
1122
1123 <Para>
1124 It is not possible to directly export operator symbols.
1125 </Para>
1126 </ListItem>
1127 <ListItem>
1128
1129 <Para>
1130 The type checker will verify that the type given for the
1131 <Literal>foreign export</Literal> declaration is compatible with the type given to
1132 function definition itself.  The type in the <Literal>foreign export</Literal> may
1133 be less general than that of the function itself.  For example,
1134 this is legal:
1135
1136
1137 <ProgramListing>
1138    f :: Num a =&#62; a -&#62; a
1139    foreign export ccall "fInt"   f :: Int -&#62; Int
1140    foreign export ccall "fFloat" f :: Float -&#62; Float
1141 </ProgramListing>
1142
1143
1144 These declarations export two C-callable procedures <Literal>fInt</Literal> and
1145 <Literal>fFloat</Literal>, both of which are implemented by the (overloaded)
1146 Haskell function <Function>f</Function>.
1147
1148 </Para>
1149 </ListItem>
1150 <ListItem>
1151
1152 <Para>
1153 The <Literal>foreign export</Literal>ed IO action must catch all exceptions, as
1154 the FFI does not address how to signal Haskell exceptions to the
1155 outside world.
1156 </Para>
1157 </ListItem>
1158
1159 </ItemizedList>
1160
1161 </Para>
1162
1163 <Sect2 id="sec-callback">
1164 <Title>Exposing Haskell function values
1165 </Title>
1166
1167 <Para>
1168 The <Literal>foreign export</Literal> declaration gives the C programmer access to
1169 statically defined Haskell functions. It does not allow you to
1170 conveniently expose dynamically-created Haskell function values as C
1171 function pointers though. To permit this, the FFI supports
1172 <Emphasis>dynamic</Emphasis> <Literal>foreign export</Literal>s:
1173 </Para>
1174
1175 <Para>
1176
1177 <ProgramListing>
1178 topdecl 
1179   : ...
1180   ..
1181   | 'foreign' 'export' [callconv] 'dynamic' varid :: prim_type -&#62; IO Addr
1182 </ProgramListing>
1183
1184 </Para>
1185
1186 <Para>
1187 A <Literal>foreign export dynamic</Literal> declaration declares a C function
1188 pointer <Emphasis>generator</Emphasis>. Given a Haskell function value of some restricted
1189 type, the generator wraps it up behind an externally callable interface,
1190 returning an <Literal>Addr</Literal> to an externally callable (C) function pointer.
1191 </Para>
1192
1193 <Para>
1194 When that function pointer is eventually called, the corresponding
1195 Haskell function value is applied to the function pointer's arguments
1196 and evaluated, returning the result (if any) back to the caller.
1197 </Para>
1198
1199 <Para>
1200 The mapping between the argument to a <Literal>foreign export dynamic</Literal>
1201 declaration and its corresponding C function pointer type, is as
1202 follows:
1203 </Para>
1204
1205 <Para>
1206
1207 <ProgramListing>
1208 typedef cType[[Res]] (*Varid_FunPtr)
1209         (cType[[Ty_1]] ,.., cType[[Ty_n]]);
1210 </ProgramListing>
1211
1212 </Para>
1213
1214 <Para>
1215 where <Literal>cType[[]]</Literal> is the Haskell to C type mapping presented
1216 in Section <XRef LinkEnd="sec-mapping">.
1217 </Para>
1218
1219 <Para>
1220 To make it all a bit more concrete, here's an example:
1221 </Para>
1222
1223 <Para>
1224
1225 <ProgramListing>
1226 foreign export dynamic mkCallback :: (Int -&#62; IO Int) -&#62; IO Addr
1227
1228 foreign import registerCallback :: Addr -&#62; IO ()
1229
1230 exportCallback :: (Int -&#62; IO Int) -&#62; IO ()
1231 exportCallback f = do
1232   fx &#60;- mkCallback f
1233   registerCallback fx
1234 </ProgramListing>
1235
1236 </Para>
1237
1238 <Para>
1239 The <Literal>exportCallback</Literal> lets you register a Haskell function value as
1240 a callback function to some external library. The C type of the
1241 callback that the external library expects in <Literal>registerCallback()</Literal>,
1242 is:
1243 <Footnote>
1244 <Para>
1245 An FFI implementation is encouraged to generate the C typedef corresponding
1246 to a <Literal>foreign export dynamic</Literal> declaration, but isn't required
1247 to do so.
1248 </Para>
1249 </Footnote>
1250
1251 </Para>
1252
1253 <Para>
1254
1255 <ProgramListing>
1256 typedef HsInt (*mkCallback_FunPtr) (HsInt arg1);
1257 </ProgramListing>
1258
1259 </Para>
1260
1261 <Para>
1262 Creating the view of a Haskell closure as a C function pointer entails
1263 registering the Haskell closure as a 'root' with the underlying
1264 Haskell storage system, so that it won't be garbage collected. The FFI
1265 implementation takes care of this, but when the outside world is
1266 through with using a C function pointer generated by a <Literal>foreign
1267 export dynamic</Literal> declaration, it needs to be explicitly freed. This is
1268 done by calling:
1269 </Para>
1270
1271 <Para>
1272
1273 <ProgramListing>
1274 void freeHaskellFunctionPtr(void *ptr);
1275 </ProgramListing>
1276
1277 </Para>
1278
1279 <Para>
1280 In the event you need to free these function pointers from within
1281 Haskell, a standard 'foreign import'ed binding of the above C entry
1282 point is also provided,
1283 </Para>
1284
1285 <Para>
1286
1287 <ProgramListing>
1288 Foreign.freeHaskellFunctionPtr :: Addr -&#62; IO ()
1289 </ProgramListing>
1290
1291 </Para>
1292
1293 </Sect2>
1294
1295 <Sect2 id="sec-foreign-label">
1296 <Title>Code addresses
1297 </Title>
1298
1299 <Para>
1300 The <Literal>foreign import</Literal> declaration allows us to invoke an external
1301 function by name from within the comforts of the Haskell world, while
1302 <Literal>foreign import dynamic</Literal> lets us invoke an external function by
1303 address. However, there's no way of getting at the code address of
1304 some particular external label though, which is at times useful,
1305 e.g. for the construction of method tables for, say, Haskell COM
1306 components. To support this, the FFI has got <Literal>foreign label</Literal>s:
1307 </Para>
1308
1309 <Para>
1310
1311 <ProgramListing>
1312 foreign label "freeAtLast" addrOf_freeAtLast :: Addr
1313 </ProgramListing>
1314
1315 </Para>
1316
1317 <Para>
1318 The meaning of this declaration is that <Literal>addrOf&lowbar;freeAtLast</Literal> will now
1319 contain the address of the label <Literal>freeAtLast</Literal>.
1320 </Para>
1321
1322 </Sect2>
1323
1324 </Sect1>
1325
1326 <Sect1 id="sec-changelog">
1327 <Title>Change history
1328 </Title>
1329
1330 <Para>
1331
1332 <ItemizedList>
1333 <ListItem>
1334
1335 <Para>
1336 0.95 --&gt; 0.96:
1337
1338 <ItemizedList>
1339 <ListItem>
1340
1341 <Para>
1342 changed the C representation of <Literal>Haskell&lowbar;ForeignObj</Literal> from
1343 <Literal>(long*)</Literal> to <Literal>(void*)</Literal> -- ANSI C guarantees that <Literal>(void*)</Literal>
1344 is the widest possible data pointer.
1345 </Para>
1346 </ListItem>
1347 <ListItem>
1348
1349 <Para>
1350 Updated defnition of <Literal>varid</Literal> in Section
1351 <XRef LinkEnd="sec-prim-name"> to reflect Haskell98's.
1352 </Para>
1353 </ListItem>
1354 <ListItem>
1355
1356 <Para>
1357 Replaced confusing uses of <Literal>stdcall</Literal> with <Literal>ccall</Literal>.
1358 </Para>
1359 </ListItem>
1360
1361 </ItemizedList>
1362
1363 </Para>
1364 </ListItem>
1365 <ListItem>
1366
1367 <Para>
1368 0.96 --&gt; 0.97:
1369
1370 <ItemizedList>
1371 <ListItem>
1372
1373 <Para>
1374 Simplified the calling convention section, support for Pascal (and
1375 fastcall) calling conventions dropped. 
1376 </Para>
1377 </ListItem>
1378 <ListItem>
1379
1380 <Para>
1381 Clarified that the arguments to a safe <Literal>foreign import</Literal> must have
1382 lifetimes that equal that of a C function application.
1383 </Para>
1384 </ListItem>
1385 <ListItem>
1386
1387 <Para>
1388 Outlawed the use of the (GHC specific) types <Literal>ByteArray</Literal>
1389 and <Literal>MutableByteArray</Literal> in safe <Literal>foreign import</Literal>s.
1390 </Para>
1391 </ListItem>
1392 <ListItem>
1393
1394 <Para>
1395 Added a note that support for the use of unboxed types in
1396 <Literal>foreign import</Literal> may be withdrawn/deprecated sometime in the future.
1397 </Para>
1398 </ListItem>
1399 <ListItem>
1400
1401 <Para>
1402 Simplified section which sketches a possible implementation.
1403 </Para>
1404 </ListItem>
1405 <ListItem>
1406
1407 <Para>
1408 Use <Literal>Hs</Literal> as prefix for the typedefs for the primitive Haskell
1409 FFI types rather than the longer <Literal>Haskell&lowbar;</Literal>.
1410 </Para>
1411 </ListItem>
1412
1413 </ItemizedList>
1414
1415 </Para>
1416 </ListItem>
1417 <ListItem>
1418
1419 <Para>
1420 0.97 --&gt; 0.98:
1421
1422 <ItemizedList>
1423 <ListItem>
1424
1425 <Para>
1426 Leave out implementation section; of limited interest.
1427 </Para>
1428 </ListItem>
1429 <ListItem>
1430
1431 <Para>
1432 Outlined the criteria used to decide on what calling
1433 conventions to support.
1434 </Para>
1435 </ListItem>
1436 <ListItem>
1437
1438 <Para>
1439 Include <Literal>newtype</Literal>s that wrap primitive types in the list
1440 of types that can be both passed to and returned from external
1441 functions.
1442 </Para>
1443 </ListItem>
1444
1445 </ItemizedList>
1446
1447 </Para>
1448 </ListItem>
1449 <ListItem>
1450
1451 <Para>
1452 0.98 --&gt; 0.99:
1453
1454 <ItemizedList>
1455 <ListItem>
1456
1457 <Para>
1458 Updated the section on type mapping to integrate some comments
1459 from people on &lt;ffi@haskell.org&gt; (a fair chunk of the text
1460 in that section was contributed by Sven Panne.)
1461 </Para>
1462 </ListItem>
1463 <ListItem>
1464
1465 <Para>
1466 <Function>freeHaskellFunctionPtr</Function> should belong to module <Literal>Foreign</Literal>, not <Literal>IOExts</Literal>.
1467 </Para>
1468 </ListItem>
1469
1470 </ItemizedList>
1471
1472
1473 </Para>
1474 </ListItem>
1475 <ListItem>
1476
1477 <Para>
1478 0.99 --&gt; 0.99.1:
1479
1480 <ItemizedList>
1481 <ListItem>
1482
1483 <Para>
1484 <Literal>Bool</Literal> is now an FFI-supported type (i.e., added it to
1485 <Literal>ext&lowbar;ty</Literal>.)
1486 </Para>
1487 </ListItem>
1488
1489 </ItemizedList>
1490
1491
1492 </Para>
1493 </ListItem>
1494
1495 </ItemizedList>
1496
1497 </Para>
1498
1499 </Sect1>
1500
1501 </Article>