Bernard James POPE bjpop@cs.mu.OZ.AU
Tue, 19 Mar 2002 13:07:06 +1100 (EST)

> > If it's a global symbol, you should be able to access it form the ffi.
> > 
> > If you want to traverse data structures the way you can using the
> > HugsInternals library, you might want to tweak the code a little to
> > provide a similar semantics/ API.  Basically, all you have to do is
> > take the C code and split it into handy bits.
> This is a nice idea - we'll be happy to incorporate the changes.


I'm on to it.

Let's presume for the moment that I will solve a simpler problem,
before I get the full task done.

Say, for argument's sake, that I want to make the function
printObj() available in Haskell, where:

   void printObj (StgClosure *obj);

(as defined in and exported from rts/Printer.c)

In Haskell I want to reflect this as:

   printObj :: a -> IO ()

Alistair mentioned that I could use the FFI to access some C code
in the RTS.

My intuition would have been to go about adding a primop as described in
/ghc/compiler/prelude/primops.txt (ie without calling through the FFI).

My trouble is I can't find any examples that are greatly similar to what
I want to do.

My question is: should I implement it through the FFI or as a primitive
ala primops.txt? Perhaps they amount to much the same thing.