Distributing a Haskell program as C source

后端 未结 7 1805
时光取名叫无心
时光取名叫无心 2021-02-06 22:57

Say I have a Haskell program or library that I\'d like to make accessible to non-Haskellers, potentially C programmers. Can I compile it to C using GHC and then distribute this

7条回答
  •  温柔的废话
    2021-02-06 23:42

    Say I have a Haskell program or library that I'd like to make accessible to non-Haskellers, potentially C programmers. Can I compile it to C using GHC and then distribute this as a C source

    You can compile to C, but the resulting C is not human-readable. You're better off writing header files and using the excellent C FFI alongside it. In any case, distributing the generated C seems like a fool's errand.

    Basically I'm interested in being able to write portions of programs in C and Haskell, and then distributing it as a tarball, but without requiring the target to have GHC and Cabal installed.

    I do not know of any solutions that do not involve GHC. You'd have to distribute at the very least the Haskell RTS.

提交回复
热议问题