Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Python code within Haskell

Tags:

python

haskell

I have a bunch (or will have a bunch) of Python code that uses the OpenCV libraries, as well as SimpleCV. I also have a bunch of Haskell code that does some other stuff, but wants to call one function that I define in the Python. This one function returns a three-tuple of doubles.

What's the best way to go about calling this function in Haskell?

For instance, a simplified case is if I have a function in Python

# foo.py
import SimpleCV

def foo():
   return (1.0,2.0,3.0)

I want to be able to do this in Haskell

-- bar.hs

main = do
  putStrLn $ show pyThingy.foo

I've tried using MissingPy (http://hackage.haskell.org/package/MissingPy), but whenever I try to import the local file I just get

*** Exception: <<MissingPy.Python.Types.PyException>>

Thanks!

like image 393
Tetigi Avatar asked Feb 17 '23 21:02

Tetigi


1 Answers

You can use Thrift. It's for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.

like image 133
Xiao Jia Avatar answered Feb 20 '23 17:02

Xiao Jia