4 ms·
Fortunately, GHC can build shared libraries on some platforms, which makes it fairly easy to expose Haskell functions to C: - Using the FFI one can specify for
by danieldk 14y ago
Fortunately, GHC can build shared libraries on some platforms, which makes it fairly easy to expose Haskell functions to C:
- Using the FFI one can specify foreign exports.
- The runtime and garbage collector can be initialized/deinitialized by adding an object file that uses gcc's constructor/destructor attributes.
- Multiple calls to hs_init (one for each library) are allowed, as long as they are balanced by hs_exits.
- It's ok to have multiple root modules.
- exDM69 14y agoIndeed, the FFI in GHC is one of the best ones out there. It makes it convenient to call C from Haskell and vice versa(!). I wish every language had an FFI and RTS that good!