4 ms·
I am not aware of any limitations, except for the static linking caveat noted in the README. The build process is also a bit involved; see the Makefile for det
by mietek 12y ago
I am not aware of any limitations, except for the static linking caveat noted in the README. The build process is also a bit involved; see the Makefile for details.
My use case involves shipping Haskell plugins for C programs to end-users, without requiring any Haskell to be installed. Hence, statically linking all Haskell libraries into the plugin binary. On Linux, this is slightly inconvenient, as GHC packages are not usually compiled with -fPIC, so some recompilation is in order. On OS X, all code is always position-independent.
As for your other question — calling C from Haskell is very easy, and there is a lot of examples.
http://hackage.haskell.org/packages/search?terms=bindings http://hackage.haskell.org/packages/search?terms=bindings
- geofft 12y agoSure, I've played with Haskell-to-C FFI before (a very tiny bit). I'm curious if there are some complications with C->Haskell->C, but maybe not. I'm strongly thinking that Haskell has an advantage here because "well, what if the Haskell function fails" or "well, what if the C function fails" is well-defined by the type system.... Can you return a pointer/reference to a Haskell object to C on one thread, and then call Haskell functions on it from another C thread?
- mietek 12y agoYes. You can use stable pointers for this purpose. A stable pointer is a reference to a Haskell expression that is guaranteed not to be affected by garbage collection, i.e., it will neither be deallocated nor will the value of the stable pointer itself change during garbage collection (ordinary references may be relocated during garbage collection). Consequently, stable pointers can be passed to foreign code, which can treat it as an opaque reference to a Haskell value. https://hackage.haskell.org/package/base-4.7.0.1/docs/Foreign-StablePtr.html https://hackage.haskell.org/package/base-4.7.0.1/docs/Foreig...