[Haskell-cafe] Injecting Haskell into C

Roman Cheplyaka roma at ro-che.info
Wed Sep 24 06:04:38 EDT 2008

I have a C function whose behaviour is customized by user-supplied
function (think of libc qsort). Typically these user-supplied functions
are written in C, but I'd like to use FFI to write them in Haskell.
Precisely, I'd like to write high-order function which will generate
these functions (e.g. mkCompare :: ... -> (Ptr a -> Ptr a -> Int) for
feeding the result to qsort).

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?

Roman I. Cheplyaka :: http://ro-che.info/
kzm: My program contains a bug. How ungrateful, after all I've done for it.

More information about the Haskell-Cafe mailing list