在Frege中与Java的互操作性,特别是在IO Monad中
我想将这段java代码翻译成Frege Haskell:在Frege中与Java的互操作性,特别是在IO Monad中,java,haskell,frege,Java,Haskell,Frege,我想将这段java代码翻译成Frege Haskell: PApplet pApplet = new PApplet(); System.out.print(pApplet.toString()); PApplet.runSketch(new String[]{"test"}, pApplet); 到目前为止,我做到了: data PApplet = mutable native processing.core.PApplet where native ne
PApplet pApplet = new PApplet();
System.out.print(pApplet.toString());
PApplet.runSketch(new String[]{"test"}, pApplet);
到目前为止,我做到了:
data PApplet = mutable native processing.core.PApplet
where
native new :: () -> IO PApplet
native toString :: PApplet -> IO String
native runSketch processing.core.PApplet.runSketch
:: ArrayOf RealWorld String -> PApplet -> IO ()
main _ = do p <- PApplet.new
pStr <- p.toString
putStrLn pStr
args = JArray.fromList ["test"]
runSketch args p
我正在努力满足编译器标准,但没有成功。经过无数次的随机组合,上面的这段代码对我来说似乎是最合理的。我是否需要在Do
块中输入提示?我不明白你为什么要这么做
ST s X
你想要什么
X
你现在在IO
,这只不过是ST RealWorld
因此,最自然的解决方案是用
来回答=
,我对弗雷格不熟悉,所以我假设它与哈斯克尔非常相似。您声明PApplet.new
具有类型()->IO PApplet
,但您使用它时没有参数:p是,调用PApplet.new
而不使用()
是大多数编译器抱怨的原因!我真的很傻。现在的问题只是关于如何摆脱进程。fr:14:expression fromList(“test”:[])中的类型错误类型是:STMutable t1(JArray字符串)expected:ArrayOf reallworld String
X
args = JArray.fromList ["test"]
type ArrayOf a x = Mutable a (JArray x)
type STMutable s a = ST s (Mutable s a)
ST s (Mutable s (JArray String))
ST s (ArrayOf s String)