Joe
Joe

Reputation: 1564

How do you call a void C function in Haskell

I am attempting to call the main function of a C file in Haskell using the foreign function interface.

The main function is declared:

int main(void);

I am unable to figure out what to tell the Haskell function to do with the void type. I am unable to modify the C source code.

Any help is appreciated.

Upvotes: 3

Views: 1206

Answers (1)

shachaf
shachaf

Reputation: 8930

A function that "takes" void like that in C takes no arguments (this looks like more of a C question than a Haskell question). The type to import it with would just be IO Int.

(Note that it may not be a good idea to call an actual main function from Haskell via the FFI. But that's up to you.)

Upvotes: 6

Related Questions