从Java内部调用Haskell函数的最佳方法 [英] Best way to call Haskell functions from within Java

查看:185
本文介绍了从Java内部调用Haskell函数的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从Java程序中执行Haskell函数的有效方法。我曾考虑过使用exec()与GHC进行交互,但似乎应该有更好的方法。 解决方案

我通常避免使用JNI类型的方法来跨运行时/语言进行链接。他们只是有太多的陷阱而且没有多少好处。我发现跨越流程边界工作更容易。尽管我从来没有用Haskell和Java进行过试验,但他们都有支持XML RPC的库,这听起来很适合你正在做的事情。所以:设置一个Haskell程序作为服务,只需在需要时调用它的功能即可。


I'm looking an efficient way of executing Haskell functions from within a Java program. I've considered the use of exec() to interact with GHC, but it seems like there should be a better method.

解决方案

I usually avoid JNI-type approaches to linking across runtimes/languages. They just have too many gotchas and little upside. I find it easier to work across process boundaries. While I've never tried it with Haskell and Java, they both have libraries that support XML RPC, and it sounds like a natural fit for what you're doing. So: set up a Haskell program as a "service" and just call its functions when you need them.

这篇关于从Java内部调用Haskell函数的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆