Add the ability to statically define a `FunPtr` to a haskell function
|Reported by:||pcapriotti||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:|
Lauri Alanko suggests that there should be a way to define a callback to a haskell function statically (i.e. without using a dynamic wrapper).
It is currently possible to do so only by exporting the function and reimporting it as a function pointer:
foreign export ccall "my_callback" myCallback :: IO () foreign import ccall "&my_callback" myCallbackPtr :: FunPtr (IO ())
but of course this not ideal because it creates an extra symbol (and is quirky).
A possible new syntax could be:
foreign import ccall myCallbackPtr :: FunPtr (IO ()) = myCallback
or variations thereof. We probably want to keep import (rather than export or some new keyword), since this declaration brings something into scope, like a normal FFI import.