On 28-Mar-2000, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote:
> Tue, 28 Mar 2000 20:14:26 +1000, Fergus Henderson <[EMAIL PROTECTED]> pisze:
> 
> > For type constructors like `->', `[]', and `Maybe', which (unlike
> > StablePtr) don't have any C equivalent, I think you probably need
> > to drop the structure, and just keep the top-level type constructor,
> > thus mapping that type to just `struct HsStablePtrFunc *'.
> 
> What about StablePtr SomeUserDefinedTypeConstructor?

        `struct HsStablePtrSomeUserDefinedTypeConstructor *'.

Actually on second thoughts I think that should perhaps be just

        `struct HsSomeUserDefinedTypeConstructor *'

and likewise for all the other mappings from `StablePtr' types;
since the FFI always(?) requires the use of StablePtrs when passing
compound types, I think there is no need to put `StablePtr' in
the C type name.  Does that sound reasonable?

> There is no corresponding C type defined anywhere.

So let the FFI generator declare one.  There's no need to define it;
leaving it undefined means that the type remains opaque.

> > Still, just making sure that Haskell types with distinct top-level
> > type constructors get mapped to distinct C types is probably enough
> > to catch most of the type errors.
> 
> IMHO it's not worth the conceptual complication of such arbitrary
> decisions. It's not typesafe anyway.

Well, that is a judgement call I guess.  But personally I'd be happy to pay a
little conceptual complication in the FFI if it saves me a few afternoons in
the debugger wondering why my program is seg faulting.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to