<div>Hey, folks. I've got a problem which I've thought about for days.<br></div><div></div><div>I need to write a program that mixes C and haskell code. And the C code controls the procedure. In C code, I want to save a complex data strcuture defined in haskell and pass it back to a haskell function at certain time. Like the following:</div>
<div></div><div>in haskell:</div><div> data A = A {...} -- very very complex data structure</div><div></div><div> initA :: A</div><div> initA = A {...}</div><div></div><div> func :: A -> A</div><div> func a = ... -- return a new 'A'</div>
<div></div><div>in C:</div><div></div><div> main</div><div> {</div><div> a = initA</div><div> ... take some actions</div><div> a = func a;</div><div> ... take some other actions</div><div> a = func a;</div>
<div> ...</div><div> ...</div><div> }</div><div></div><div>Different from most cross-language programs, this C program doesn't alter the data in haskell, just saves it and passes it on. So I'm wondering if there's some convienent way other than marshalling the data in haskell?</div>
<div></div><div>BTW, mashalling data requires all work done in IO monad, which will change the program stucture. So I really don't want to mashal it.</div><div></div><div>Thank you!</div>