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

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

我遇到过etahttps://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. 

但是在页面的下方,有一个“即将推出”部分,其中列出了互操作性。所以我的问题是,在我忙于建立要开发的环境的麻烦之前:

这是正式支持吗?

cz289548699 回答:Eta是否可以与Java和/或Kotlin互操作?

“即将推出”的东西是“绑定生成器”。 Eta has implemented syntax用于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本身。

本文链接:https://www.f2er.com/2749758.html

大家都在问