forcing a haskell object to WHNF from C

Hi all, This might seem like a strange thing to do, but ... Presume I have a HaskellObj in some C code. I know that it is a thunk. I want to force it to _WHNF_ . Should/can I use rts_eval()? Any pointers on what this does (start new threads, cause garbage collection ...) would be appreciated. I can (and have) gone over the code but a more high level description would be helpful. Or perhaps there is another/better way. In essence I want a C version of seq (perhaps I can call to Haskell to perform a seq on it, but I think this might be overkill). A lightweight solution would be nice. Cheers, Bernie.

Should/can I use rts_eval()?
Yes.
Any pointers on what this does (start new threads, cause garbage collection ...) would be appreciated. I can (and have) gone over the code but a more high level description would be helpful.
rts_eval() may cause garbage collection to happen. This means that every HaskellObj value might be invalid after a call to rts_eval (except for the return value). rts_eval starts a new concurrent Haskell thread to do the evaluation.
In essence I want a C version of seq (perhaps I can call to Haskell to perform a seq on it, but I think this might be overkill).
Calls to Haskell are implemented using rts_eval/rts_evalIO too, so writing it in Haskell is the same thing with a little bit more overhead. Cheers, Wolfgang
participants (2)
-
Bernard James POPE
-
Wolfgang Thaller