Calling Haskell functions from Python

后端 未结 6 1999
醉话见心
醉话见心 2020-12-04 18:22

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

6条回答
  •  攒了一身酷
    2020-12-04 18:55

    Provided you can get your Python code to call C, you can call Haskell functions that have been exported via the FFI

    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.

    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.

    SWIG, alas, has, to the best of my knowledge, never been implemented for Haskell, presumably because it caters to less strictly-typed languages.

提交回复
热议问题