Another example, similar to Manuel's work but for GHCJS JavaScriptFFI is ghcjs-ffiqq: https://github.com/ghcjs/ghcjs-ffiqq . There is some automatic marshalling of arguments and results using the ToJSRef / FromJSRef typeclasses. I'm working on integrating the improvements in these typeclasses back into ghcjs-base. The quasiquoter might be moved there too, but I'm not sure yet.
The (ugly) implementation is here: https://github.com/ghcjs/ghcjs-ffiqq/blob/master/src/GHCJS/Foreign/QQ.hs Adapting to ccall imports should be straightforward, but implementing the full functionality would require a bit more stub code generation, since this code depends on GHCJS' native support for inline foreign import argument placeholders ($1, $2, $3 etc) placeholders. luite On Wed, Feb 11, 2015 at 11:40 PM, Simon Peyton Jones <[email protected]> wrote: > This may be relevant. http://www.cse.unsw.edu.au/~chak/papers/CMCK14.html > Manuel gave a talk about something like this at the Haskell Symposium. > > Simon > > | -----Original Message----- > | From: Haskell-Cafe [mailto:[email protected]] On Behalf > | Of Francesco Mazzoli > | Sent: 11 February 2015 10:26 > | To: haskell; [email protected] > | Subject: [Haskell-cafe] Anonymous FFI calls > | > | 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 > | [email protected] > | http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > ghc-devs mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/ghc-devs _______________________________________________ ghc-devs mailing list [email protected] http://www.haskell.org/mailman/listinfo/ghc-devs
