Extension to the FFI to allow macro expansions to be avoided
Sven.Panne at aedion.de
Thu Apr 15 03:08:34 EDT 2004
Fergus Henderson wrote:
> [...] I the right way to solve this is to support some way for the Haskell
> user to tell the Haskell implementation what the right type is, for example
> perhaps something along the lines of
> data WINDOW
> foreign import ccall unsafe "static curses.h wstandend" wstandend
> :: Ptr WINDOW -> IO CInt
> or perhaps the above plus a new declaration to associate the Haskell name
> "WINDOW" with the C type name "WINDOW":
> foreign type "curses.h WINDOW" WINDOW
> Then ghc could generate C code which uses "WINDOW *" rather than "void *",
> and there would be no need to use parentheses or #undef to stop the macro
> being invoked.
"foreign type" looks like something really useful and it came to my mind
several times in the past, too. But the pressure of having it was never high
enough to spend a non-trivial amount of brain-cycles, we're all lazy programmers...
While we're at it: Being able to specify "const" is high on my wish list for
some years now. And if we don't go the whole way here, I'd even be happy with
a simple way to specify a "const blah*" argument/return value.
More information about the FFI