[Haskell-cafe] Injecting Haskell into C

Evan Laforge qdunkan at gmail.com
Wed Sep 24 18:09:45 EDT 2008

> As I understand, there are two ways to do that. Either Haskell code is
> called from C, or C code is called for Haskell. So my questions are:
> 1. Are they both possible?


> 2. If yes, which is better performance-wise? (C function is
>   performance-critical). If generated function is called many times,
>   how big an overhead is going to be?

I'm also interested in an answer to this, since I have a program that
does both, quite a bit.  Of course the real answer is to try to
profile it, but I'm also interested in the theory of what's going on
in both directions (I'm using safe imports of course, since there are

I have a bit of a performance problem with the C->haskell part, but
that may also be all the marshalling the haskell side has to do (both
via the with / alloca approach, and malloc in haskell and free() in
C), and I'd like to know a bit more before I go wild trying to cache
data in C that comes from haskell.

More information about the Haskell-Cafe mailing list