simonpj at microsoft.com
Fri Apr 14 06:41:34 EDT 2006
A couple of comments about the FFI spec.
I was trying to find out whether the automatic newtype unwrapping for
'foreign' declarations was part of the FFI spec. I searched for
Turns out that the *only* reference is in the sentence in 3.2:
"The argument types ati produced by fatype must be marshallable
foreign types; that is, each
ati is either (1) a basic foreign type or (2) a type synonym or renamed
datatype of a marshallable
This is very quiet! The "renamed datatype" nomenclature is never used
in practice (only in the Haskell report), and in any case the sentence
is hard to unpick without an example or two.
Second point. Consider
foreign import "dynamic" foo :: (Int -> IO Int) -> ...
I'm not sure whether (Int -> IO Int) is considered a "marshallable
foreign type", according to the defn in 3.2.
I also found the separation of 4.1.3 from 3.2 quite hard to understand.
I was searching in 3.2 for "wrapper" and "dynamic" in vain! I don't
have a good solution to this, except perhaps some explicit fwd refs, and
a clear explanation of the logic behind the structure of the document.
Since some aspects of the FFI spec may change slightly for Haskell',
this seemed like a good moment to mention these points.
More information about the FFI