Eta 可以与 Java 和/或 Kotlin 互操作吗?



我一直在学习 Haskell,但在我白天的工作中,我正在编写 Kotlin/Java。

我遇到了Eta(https://eta-lang.org/(,一种Haskell方言,可以编译成Java字节代码并在JVM上运行。在网站上,它声明它有:

Robust Interoperability
Eta has a strongly-typed Foreign Function Interface (FFI) that allows you to safely interoperate with Java. 

但在页面的下方有一个"即将推出"部分,其中列出了互操作。所以我的问题,在我开始麻烦地设置一个开发环境之前:

这是否得到官方支持?

"即将推出"的是"绑定生成器"。Eta 已经实现了 Java 互操作的语法,但您需要为要调用的每个 Java 实体显式编写外语句。例如,在链接示例中,像这样的类

public class Counter {
private int counter = 0;
private final int max;
public Counter(int max) { this.max = max; }
public int postIncrement() { return max == counter ? counter : counter++; }
}

需要大量外国进口

data Counter = Counter @example.Counter deriving Class
foreign import java unsafe "@new" newCounter :: Int -> Java a Counter
foreign import java unsafe "postIncrement" postIncrement :: Java Counter Int

正如您可能猜到的那样,最好是自动生成的。这一代人的程序是WIP,而不是FFI本身。

最新更新