[Haskell-cafe] Anonymous FFI calls
hsyl20 at gmail.com
Wed Feb 11 17:26:10 UTC 2015
2015-02-11 16:18 GMT+01:00 Francesco Mazzoli <f at mazzo.li>:
> Relatedly, if I have some function pointer known at runtime that
> addresses a C function that takes some arguments, I have no way to
> invoke it from Haskell, since all FFI imports must be declared at
> compile-time, and I don't know the address of the symbol I want to
> execute at compile time.
You can use FunPtr and wrapper imports to convert a FunPtr into a Haskell
You may be interested in my dynamic-linker-template package  to avoid
having to write boilerplate wrappers. For now it only works with dynamic
linking from System.Posix.DynamicLinker, but it could be easily extended to
support other platforms. It automatically generates wrappers for all the
functions in a record as well as the code to load symbol addresses and to
convert them into Haskell functions (examples [2,3]).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs