从Python中调用的Haskell函数
我想从Python中使用一些哈斯克尔库(例如的darcs,Pandoc),但似乎没有外商直接函数接口哈斯克尔在Python。有没有办法做到这一点?
I want to use some Haskell libraries (e.g. Darcs, Pandoc) from Python, but it seems there’s no direct foreign function interface to Haskell in Python. Is there any way to do that?
只要你能得到你的Python code调用C,你可以调用已经通过的FFI
Provided you can get your Python code to call C, you can call Haskell functions that have been exported via the FFI
另一种方法是编写一个标准的IPC界面,在和的darcs只是pandoc调用它们香草的可执行文件,并解析其输出的情况下可能是要走的路。
Another approach would be to write a standard IPC interface, in the case of darcs and pandoc just calling them as vanilla executables and parsing their output might be the way to go.
至于自动枯燥,重复,FFI和编组code在哈斯克尔侧的一代,我建议 c2hs ,它可以让你自动生成一个基于现有的C接口上不少。有可能是蟒蛇类似的事情。
As to automating the generation of boring, repetitive, FFI and marshalling code on the Haskell side, I'd recommend c2hs, which allows you to auto-generate a lot based on an existing C interface. There's probably similar things for python.
痛饮,唉,已经到了我所知,从来没有Haskell的实施,presumably因为它迎合少严格类型语言。
SWIG, alas, has, to the best of my knowledge, never been implemented for Haskell, presumably because it caters to less strictly-typed languages.