Revised FFI syntax + typing

Manuel M. T. Chakravarty chak at cse.unsw.edu.au
Sun May 6 09:51:07 EDT 2001


"Simon Marlow" <simonmar at microsoft.com> wrote,

> > > Why is Word a GHC extension?  Someone remind me?
> > 
> > Hmmm, I thought that the Word type itself is a GHC extension, the
> > hslibs docs for module Word only talk about the explictly sized
> > variants. OTOH the implementation exports Word, but for legacy
> > reasons, IIRC. If this is really the case, we should document this
> > somehow in the sources.
> 
> I don't think I have any strong feelings either way.  Word has a
> pleasing symmetry with Int, but on the other hand if it isn't useful
> then we should omit it.  I agree in principle with Alastair's
> portability argument, but don't think it is worth applying for this
> particular case since we already have Int.

I mostly agree with Simon.  There is no point in trying to
fix a problem that H98 already introduced.  The H98
Committee in their infinite wisdom chose to have types with
system-dependent sizes and I think, we should be as
orthogonal as possible whether we like it or not.

Moreover,

> In the absence of a Bits Int instance I would have to write the code
> like this:
> 
> -- this code to go in the same file as the code that assumes that
> -- Int and Int32 are isomorphic
> #if sizeof_Int == 32
> type Intlike = Int32
> toIntlike = intToInt32  -- or fromIntegral
> fromIntlike = int32ToInt
> #elif sizeof_Int == 64
> type Intlike = Int64
> toIntlike = ...
> fromIntlike = ...
> #else
> #warning ...
> #endif

Interesting language, but can anyone remind me what these
#if etc are supposed to me - I can't find them in the
Haskell report.

Cheers,
Manuel




More information about the FFI mailing list