<div>Hey, folks. I&#39;ve got a problem which I&#39;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 -&gt; A</div><div>  func a = ... -- return a new &#39;A&#39;</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&#39;t alter the data in haskell, just saves it and passes it on. So I&#39;m wondering if there&#39;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&#39;t want to mashal it.</div><div></div><div>Thank you!</div>