I am interfacing to a C library, and there's a function
that has a callback argument of type (int (*fun) (void *))
.
How would I handle this with c2hs
? I don't see callbacks mentioned in
https://github.com/haskell/c2hs/wiki/Implementation-of-Haskell-Binding-Modules or http://www.cse.unsw.edu.au/~chak/papers/Cha99b.html .
In my actual application, the callback does not do any computation - it just needs to check whether some flag was set meanwhile, and I want to set it from a Haskell thread. (So the obvious work-around is to declare the callback, and the flag, in C land, and have a Haskell function just set the flag.)
(Edit) I also checked https://wiki.haskell.org/Calling_Haskell_from_C but rejected it because of "ghc -c ... will create Safe_stub.c ..." and I was sure that compilation to C was long gone. But indeed I get a stub.h (do I need it?) and the object file.