forcing a haskell object to WHNF from C

Simon Marlow
Wed, 29 Jan 2003 11:04:41 -0000

> 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()?=20
> Any pointers on what this does (start new threads, cause=20
> garbage collection
> ...) would be appreciated. I can (and have) gone over the=20
> 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).=20
> A lightweight solution would be nice.

rts_eval() is the right way to do it, but it isn't particularly
lightweight: it creates a new thread to do the evaluation.  I imagine
you could have a special-purpose thread that you keep around purely for
doing these evaluations, if efficiency is important to you.