[nhc-users] FFI "wrapper"

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Oct 8 06:06:03 EDT 2008


Donn, sorry I didn't see your message until now - it got filtered away
to a different mailbox during ICFP.

> Just this weekend I got nhc98 running on a platform where I've wanted
> a Haskell compiler for a long time, very thrilling.  But of course
> nothing's ever perfect, and apparently there's no foreign import
> "wrapper"  support, which I think is what I would use to pass Haskell
> functions to C.

You are right, nhc98 does not support "foreign import wrapper".  The
main problem is generating machine code on-the-fly.  One possibility
would be to steal ghc's Adjustor code.  Another route might be to change
all the FFI backend code over to using libFFI, as yhc (based on nhc98)
has already done, and as I think ghc has also done recently.  (However, I
believe yhc never attempted to implement "foreign import wrapper"
either.)

> While I'm at it - if I manage to get callbacks working - they'll be
> coming from various different OS-level threads, so ... I will need to
> protect against concurrent execution, right?

nhc98's runtime system is single-threaded, but assuming that the
functions you export are pure, I don't see how that is a problem.  I
suppose you would need somehow to route all callbacks into the OS thread
that contained the (single) nhc98 runtime system?

Yhc has concurrent Haskell-level threads, but again they are contained
within a single OS-level thread.

Regards,
    Malcolm


More information about the Nhc-users mailing list