[Haskell-cafe] Anonymous FFI calls
Simon Peyton Jones
simonpj at microsoft.com
Wed Feb 11 23:25:49 UTC 2015
I would LOVE someone to improve the documentation for addTopDecls. Manuel Chakravarty and Geoff Mainland were responsible for the implementation.
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Michael
| Sent: 11 February 2015 23:19
| To: Francesco Mazzoli
| Cc: ghc-devs at haskell.org; haskell
| Subject: Re: [Haskell-cafe] Anonymous FFI calls
| It seems like addTopDecls will able to help here. Unfortunately,
| the function is not well documented and not very discoverable because
| it's only exported by Language.Haskell.TH.
| The documentation doesn't mention that it can only be used to create
| new top level functions and FFI imports. I think that adding FFI
| imports was the main motivation for implementing it. In the past
| I've wanted to generate instances via this function, but unfortunately
| it's not implemented..
| Hope that helps!
|  http://hackage.haskell.org/package/template-haskell-
| On Wed, Feb 11, 2015 at 2:26 AM, Francesco Mazzoli <f at mazzo.li> wrote:
| > Hi,
| > I am in a situation where it would be very useful to call C functions
| > without an explicit FFI import. For example, I'd like to be able to do
| > (foreign import ccall "cadd" :: CInt -> CInt -> CInt) 1 2
| > instead of declaring the foreign import explicitely at the top level.
| > Is there a way to do this or to achieve similar results in some other
| > way?
| > If not, I imagine it would be easy to implement such a facility in GHC,
| > given that the code implementing calling to C functions must already be
| > present to implement "proper" FFI imports. I think such an addition
| > would be useful in many cases.
| > Thanks,
| > Francesco
| > _______________________________________________
| > Haskell-Cafe mailing list
| > Haskell-Cafe at haskell.org
| > http://www.haskell.org/mailman/listinfo/haskell-cafe
| ghc-devs mailing list
| ghc-devs at haskell.org
More information about the Haskell-Cafe