你知道我在哪里可以找到有关 Frege 的 Java 绑定的文档吗?来自 Haskell,我发现 Frege 最有趣的方面。不幸的是,我发现的文档并没有详细说明。
这是我的测试示例。基本上,我想翻译以下 Java 代码:
BigDecimal x = BigDecimal.valueOf(7);
BogDecimal y = new BigDecimal("5.13");
System.out.println(x.add(y));
这是我当前的弗雷格代码:
module Main where
data JBigDecimal s = pure native java.math.BigDecimal
where
pure native jAdd add :: JBigDecimal RealWorld -> JBigDecimal RealWorld -> JBigDecimal RealWorld
pure native jShow toString :: JBigDecimal RealWorld -> String
pure native jBigDecimalI java.math.BigDecimal.valueOf :: Int -> JBigDecimal RealWorld
-- ERROR: Here, I don't know what I should write.
-- I want to bind to the BigDecimal(String) constructor.
-- I tried several versions but none of them was successful, e.g.:
pure native jBigDecimalS java.math.BigDecimal.BigDecimal :: String -> JBigDecimal RealWorld
main :: [String] -> IO ()
main args = let x = jBigDecimalI 7
y = jBigDecimalS "5.13"
z = JBigDecimal.jAdd x y
in printStrLn $ (JBigDecimal.jShow z)
-- (BTW, why `printStrLn` and not `putStrLn` as it is called in Haskell?)
为了完整起见,错误消息是:
calling: javac -cp fregec-3.21.jar:. -d . -encoding UTF-8 ./Main.java
./Main.java:258: error: cannot find symbol
return java.math.BigDecimal.BigDecimal(
^
symbol: method BigDecimal(String)
location: class BigDecimal
1 error
E frege-repl/example.fr:15: java compiler errors are most likely caused by
erronous native definitions