[英]Mapping Java Array to Frege
Lets say I'd like to map the Java code: 让我们说我想映射Java代码:
package mypackage;
class A {
public String[] values() {
return new String[]{"one", "two"};
}
}
To its Frege counterpart: 对弗雷格的同行:
data AA = pure native mypackage.A where
native values :: AA -> [String]
At the moment Frege complains with: 目前弗雷格抱怨:
error: incompatible types: String[] cannot be converted to TList
How can I map a Java array to Frege ? 如何将Java数组映射到Frege?
The message is actually from the Java compiler. 该消息实际上来自Java编译器。
The Frege type that corresponds to a Java array 与Java数组对应的Frege类型
Foo[]
is 是
JArray Bar
where Bar
is the Frege type that corresponds to Foo
. 其中
Bar
是与Foo
对应的Frege类型。
So, in your case it should be 所以,在你的情况下它应该是
JArray String
Note that this is an immutable array from the Frege point of view. 请注意,从弗雷格的角度来看,这是一个不可变的数组。 If you want a mutable array, use
如果你想要一个可变数组,请使用
Mutable s (JArray String)
but, of course, it can only be used in the ST monad. 但是,当然,它只能用于ST monad。
Here is the link to the relevant online doc: http://www.frege-lang.org/doc/frege/prelude/PreludeArrays.html Because this is part of Prelude, you don't need to import anything to use it. 以下是相关在线文档的链接: http : //www.frege-lang.org/doc/frege/prelude/PreludeArrays.html因为这是Prelude的一部分,所以您无需导入任何内容即可使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.