How are functions passed from the interpreter to the host? #127
Unanswered
LukaHorvat
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The interpreter is not a separate process, so there is no need to marshall anything. I'd expect both |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So briefly what I'm trying to do is write a game in Haskell, and the engine I'm using requires me to build my code into a dll with takes ages on Windows. I want to speed up my iteration cycle so I thought I'd just compile the dll once and then dynamically interpret my Haskell scripts.
From the type level it seems I've managed to set everything up, my code compiles and runs, I can see the output. The issue is that the engine starts complaining that something internal isn't initialized when the interpreted code calls some of the engine API and I'm unsure why that is.
The way I'm doing it is that I have a
ready :: EngineState -> IO ()
function in a separate module that uses the engine API on theEngineState
. I interpret that module and pass theready
function back to the host withinterpret "ready" (as :: EngineState -> IO ())
. Then I call that function in the actually compiled part of my code.Does this have any chance of working? What I thought was that maybe when I get this function back to the host, it's only a shim that marshals the inputs to the interpreter, then runs the code there and then marshals the results back. In that case it would make sense that things like internal
MVars
and whatnot don't survive the process. At least not with correct semantics.The thing is, I've tried a simpler program that just sets the provided
MVar
and it's effects are indeed visible in the host so I'm not sure anymore.Beta Was this translation helpful? Give feedback.
All reactions