[GHC] #7048: Add the ability to statically define a `FunPtr` to a haskell function
GHC
cvs-ghc at haskell.org
Wed Jul 4 17:52:49 CEST 2012
#7048: Add the ability to statically define a `FunPtr` to a haskell function
---------------------------------+------------------------------------------
Reporter: pcapriotti | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.4.2
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Lauri Alanko [http://haskell.1045720.n5.nabble.com/Static-non-exported-
stubs-td5713489.html 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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7048>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list