How to save a haskell data structure in C?

Shu Wu superwushu at
Fri Jul 3 05:23:22 EDT 2009

Hey, folks. I've got a problem which I've thought about for days.
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:
in haskell:
   data A = A {...} -- very very complex data structure
  initA :: A
  initA = A {...}
  func :: A -> A
  func a = ... -- return a new 'A'
in C:
     a = initA
     ... take some actions
     a = func a;
     ... take some other actions
     a = func a;
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?
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.
Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list