comments on FFI 1.4

Marcin 'Qrczak' Kowalczyk qrczak at
Wed Jun 13 15:27:24 EDT 2001

On Wed, Jun 13, 2001 at 04:22:16AM +1000, Fergus Henderson wrote:

>         - Should `CInt' be guaranteed to have the same representation
>           as C's `int', or just the same range of values?

You can't discover the actual representation anyway. What it
guaranteed is that you can write CInt on the Haskell side and it
will correctly call a C function declared with int, and vice versa
for exporting, with all values preserved, and that the Bounded CInt
instance corresponds to INT_{MIN,MAX} in C, and that the Storable CInt
instance works in the same way as storing ints under pointers in C,
and some other instances should match the corresponding C behavior
(these things are probably nowhere explicitly said but should be).

How the Haskell implementation manages to provide it is its private
business. For example in ghc all Int8, Int16 and Int32 (and Int64 on
a 64-bit platform) have the same internal representation.

 __("<  Marcin Kowalczyk * qrczak at
  ^^                      SYGNATURA ZASTĘPCZA

More information about the FFI mailing list