[Haskell-cafe] hsffig issues (was: Suggestions for #defines with
dimitry at golubovsky.org
Thu Jul 28 00:08:11 EDT 2005
John Goerzen wrote:
> Incidentally, I looked at hsffig. There were a couple issues with using
> it for this:
> 1) It didn't declare types for the imported constants, so Haddock
> wouldn't generate a list over it.
I never tried to make hsffig output documentable: the whole idea is just
to write "import FOO_H" in Haskell as one would write "#include <foo.h>"
> 2) It included all sorts of other #defined items, from other headers
> (stdio.h maybe), making it unsuitable to re-export directly to the user.
> (I'd have to re-key everything anyway)
I mentioned this in the Tutorial: hsffig gives the Haskell compiler the
same look at information about the library to import as the C compiler
would have. It is hard to separate such things: your header file that
you include may include ten other headers, five of them related to the
library, and the rest from /usr/include
And you do not need to reexport because wherever you need the bindings,
you just import them there. You still have to have some library
interface layer in your application, but you do not focus on type
signatures of foreign functions.
> 3) It tried to list some of the GCC internal conditionals as constants,
> making the .hsc not compile unless I manually removed some of them.
Can you provide an example of that? With (almost antique) egcs-2.91.66 I
never had anything like this. What was in the .hsc file and what was the
> I really like the idea, though. Autodetecting these is great, since
> they could vary somewhat from implementation to implementation.
Exactly: the Haskell compiler gets the same information (e. g. from
features.h) as the C compiler got when compiling the library.
More information about the Haskell-Cafe