[Haskell-cafe] example of FFI FunPtr
vigalchin at gmail.com
Fri Jun 6 05:06:19 EDT 2008
I want to do an incremental "experiment". I want just want to pass a C
function to "callback" to a Haskell function. ???
On Thu, Jun 5, 2008 at 4:21 AM, Claude Heiland-Allen <
claudiusmaximus at goto10.org> wrote:
> Galchin, Vasili wrote:
>> I want to model a Haskell function that is a callback from C. I have
>> only found one example in the unix package's Semaphore.hsc, which
>> is not used. I want to be able to marshall a Haskell function that is a
>> first class citizen residing in a Haskell data type and pass to a C
>> via FFI. Are there examples of this?
> Attached is a simple example.
> The main thing to note is 'foreign import ccall "wrapper"' which gives you
> a factory for turning Haskell functions into foreign function pointers.
> More information:
> CallBacker: CallBacker.hs callerback.c callerback.h
> ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe