Also, if you always plan to partially apply your notification function and you just want a simple callback:
void (*pCallbackFn)(void); You should be able to do something like this: > type Callback = IO () > foreign import ccall "wrapper" mkCallback :: Callback -> IO (FunPtr Callback) You can then do something like > main = do > let event = Sigval { ... fill in here ... } > callback <- mkCallback (notify event) > ... > freeHaskellFunPtr callback On 6/10/08, Ryan Ingram <[EMAIL PROTECTED]> wrote: > I'm not super experienced with the FFI (foreign function interface); I > only used C types that you can get from #include <HsFFI.h>, like > Word32. > > You might need to make Sigval an instance of Storable, or do some > magic with ForeignPtrs. Good luck! :) > > -- ryan > > > On 6/9/08, Galchin, Vasili <[EMAIL PROTECTED]> wrote: > > I have tried various things to no avail .... > > > > [EMAIL PROTECTED]:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > > runhaskell Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:22:0: > > Unacceptable argument type in foreign declaration: Sigval > > When checking declaration: > > foreign import ccall safe "wrapper" mkNotify > > :: Notify -> IO (FunPtr Notify) > > > > => here is my Sigval def > > > > data Sigval = SivalInt Int | SivalPtr (Ptr Char) > > > > I did a find/grep for "Unacceptable argument" in the ghc compiler source and > > assuming no typo I didn't find. ?? > > > > Thanks. > > > > Kind regards, Vasili > > > > > > > > > > On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson <[EMAIL PROTECTED]> > > wrote: > > > > > 2008/6/9 Galchin, Vasili <[EMAIL PROTECTED]>: > > > > > > > Ryan, > > > > > > > > I tried but the compiler didn't seem to like the keyword "import": > > > > > > > > > > [EMAIL PROTECTED]:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > > runhaskell > > > > Setup.lhs build > > > > Preprocessing executables for Test-1.0... > > > > Building Test-1.0... > > > > [1 of 1] Compiling Main ( ./timer.hs, > > > > dist/build/timer/timer-tmp/Main.o ) > > > > > > > > ./timer.hs:29:8: parse error on input `import' > > > > > > > > > > Hi Vasili, > > > > > > To fix that error, you probably just need to add the line "Extensions: > > > ForeignFunctionInterface" to the .cabal file. (That is the > > > equivalent of calling ghc by itself with the command-line arguments > > > -fffi or -XForeignFunctionInterface.) > > > > > > Hope that helps, > > > -Judah > > > > > > > > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe