[Haskell-cafe] Anonymous FFI calls
vogt.adam at gmail.com
Wed Feb 11 19:32:03 UTC 2015
On Wed, Feb 11, 2015 at 12:26 PM, Sylvain Henry <hsyl20 at gmail.com> wrote:
> 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.
Code using http://hackage.haskell.org/package/libffi looks pretty
similar, though the specification needs terms (such as argCInt)
instead of a mandatory type signature. GHC itself includes libffi so
maybe the foreign import "dynamic" calls end up doing exactly the same
thing as the hackage libffi does.
More information about the Haskell-Cafe