[Haskell-cafe] Consequences of implementing a library in Haskell
for C consumption?
Don Stewart
dons at galois.com
Thu Sep 4 17:32:42 EDT 2008
jgbailey:
> I am thinking of writing a simple library in Haskell which would be
> useful in a number of different scenarios, and not always with
> programs written in Haskell. That makes me think the library should be
> C-compatible and able to link with C programs. Reading over chapter 9
> of the GHC manual ("Foreign function interface"), it seems simple to
> do.
>
> However, what are the consequences of such an implementation? Would
> any program using my library need to link the entire GHC runtime? The
Yes.
> library will not expose any higher-order functions or other business.
You still need the GHC runtime support for the Haskell code (GC,
scheduler et al).
> It would be straightforward but tedious to write in C, which is why
> I'd rather use Haskell.
Easy enough to do,
http://haskell.org/haskellwiki/Calling_Haskell_from_C
Would be great to hear how you find the experience.
-- Don
More information about the Haskell-Cafe
mailing list