Looking at the MicroHs source code, it has listings of C functions with their signatures, such that they can be used in Haskell's FFI:
* The types are
* V void name(void)
* i int name(void)
* I value_t name(voi)
* IV void name(value_t)
* II value_t name(value_t)
* IIV void name(value_t, value_t)
* III value_t name(value_t, value_t)
* DD flt_t name(flt_t)
* Pi int name(void*)
* PI value_t name(void*)
* PP void* name(void*)
* iPi int name(int, void*)
* PPI value_t name(void*, void*)
* PPP void* name(void*, void*)
and then
{ "log", (funptr_t)log, FFI_DD },
{ "exp", (funptr_t)exp, FFI_DD },
[...]
{ "fgetc", (funptr_t)fgetc, FFI_Pi },
{ "fputc", (funptr_t)fputc, FFI_iPi },
I am wondering whether such a table can't be generated automatically?
The C compiler knows about the ABIs on my system, so if it has compiled the C library, it should also contain information about the signature of e.g. log and fgetc.
How would I generate this listing automatically?