How to access defines and enums in a convenient way?
I am doing some wrappers for c functions, and I need to access defines, enums, and structs. I am doing this by writing access functions in c, so that I can call them from Haskell. Is there a way to write this c code inline in the Haskell module? Since any implementation of FFI must do this via C anyway (to access the header files), it could simply inline the code as well. It's a bit of a bother to have to specify the object files for the access functions when compiling a Haskell program, especially since I am writing library modules and the program using the library shouldn't need to bother with extra object files. Regards, Martin -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B
Martin Norbäck wrote:
I am doing some wrappers for c functions, and I need to access defines, enums, and structs. [...]
Have a look at hsc2hs: http://haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html The hierachical libraries contain a lot of examples. But note that the generated Haskell code is *not* portable across platforms, so you have to ship your *.hsc files if you want that. Cheers, S.
participants (2)
-
Martin Norbäck -
Sven Panne