我如何通过Java运行我的haskell函数 [英] How can I run my haskell functions through Java

查看:72
本文介绍了我如何通过Java运行我的haskell函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我在 math.hs 中有一个haskell函数 add



如何运行通过Java程序添加函数并将输出存储为变量?

可能类似于以下内容:

  public int runHaskell(String haskellFile){
int output;
//运行文件'math.hs'中的add函数并存储结果到输出
return output;





(如果需要,我也可以访问目标文件: math .o 和解释器文件 math.hi 以及可执行文件 main.exe 。)

解决方案

简单但笨拙的方式:
$ b

Runtime.exec()
$ b

b $ b

或者,您可以为JNI编写一个小包装,直接调用Haskell的东西。


Lets say I have a haskell function add in math.hs

How can I run the add function through a Java program and store the output as a variable?

Maybe something like the following:

public int runHaskell(String haskellFile) {
    int output;
    //run add function from file 'math.hs' and store result to output
    return output;
}

( If required I also have access to the object file: math.o and the interpreter file math.hi as well as the executable main.exe. )

解决方案

The easy (but clumsy) way:

Runtime.exec()

Then you can listen to the output of the Haskell program, and then parse it for the result.

Alternatively, you can write a small wrapper for JNI that calls directly into your Haskell stuff.

这篇关于我如何通过Java运行我的haskell函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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