thank you, Claude!<br><br>Vasili<br><br><div class="gmail_quote">On Th, Jun 5, 2008 at 4:21 AM, Claude Heiland-Allen &lt;<a href="mailto:claudiusmaximus@goto10.org">claudiusmaximus@goto10.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">Galchin, Vasili wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
 &nbsp; &nbsp; &nbsp; I want to model a Haskell function that is a callback from C. I have<br>
only found one example in the unix package&#39;s Semaphore.hsc, which apparently<br>
is not used. I want to be able to marshall a Haskell function that is a<br>
first class citizen residing in a Haskell data type and pass to a C function<br>
via FFI. Are there examples of this?<br>
</blockquote>
<br></div></div>
Attached is a simple example.<br>
<br>
The main thing to note is &#39;foreign import ccall &quot;wrapper&quot;&#39; which gives you a factory for turning Haskell functions into foreign function pointers.<br>
<br>
More information:<br>
<br>
<a href="http://www.cse.unsw.edu.au/%7Echak/haskell/ffi/" target="_blank">http://www.cse.unsw.edu.au/~chak/haskell/ffi/</a><br>
<br>
<br>
Claude<br><font color="#888888">
-- <br>
<a href="http://claudiusmaximus.goto10.org" target="_blank">http://claudiusmaximus.goto10.org</a><br>
<br>
</font><br>CallBacker: CallBacker.hs callerback.c callerback.h<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c<br>
<br></blockquote></div><br>