It'd be nice if the glue code in cbits could go away. Most of the typical definitions for NaCl functions unfortunately are hidden behind the C preprocessor though, and GHC does not parse .h files, so it depends on you specifying the function's symbol name in the library you're linking to. But we don't know that, because the functions name incorporates build-time settings, i.e. crypto_box_curve25519xsalsa20poly1305 may actually be crypto_box_curve25519xsalsa20poly1305_ref or some other arbitrary string based on CPU identifiers.
It would be awesome if there was a way to extract the #define from the header and use that in the foreign declaration.
GHC 7.4.1 apparently has some experimental support for something like this, via its (undocumented) CApiFFI extension. I'd rather be able to build it on older compilers for now, though.
It'd be nice if the glue code in
cbits
could go away. Most of the typical definitions for NaCl functions unfortunately are hidden behind the C preprocessor though, and GHC does not parse.h
files, so it depends on you specifying the function's symbol name in the library you're linking to. But we don't know that, because the functions name incorporates build-time settings, i.e.crypto_box_curve25519xsalsa20poly1305
may actually becrypto_box_curve25519xsalsa20poly1305_ref
or some other arbitrary string based on CPU identifiers.It would be awesome if there was a way to extract the
#define
from the header and use that in the foreign declaration.