我正在尝试在 PureScript 中创建一个外部常量,但它似乎没有调用该函数。
我在 PureScript 中有:
module Test where
foreign import test :: String
foreign import test2 :: String -> String
在 JavaScript 中:
"use strict";
// module Test
exports.test = function() {
return "A";
};
exports.test2 = function(x) {
return x;
};
但它没有调用外部函数:
> import Prelude
> :t test
Prim.String
> :t test2
Prim.String -> Prim.String
> test
undefined
> test2 "test"
"test"
> test ++ "A"
"function () {\n return \"A\";\n}A"
是否可以创建一个外部常量?或者所有函数都至少有一个参数吗?我正在使用:
$ pulp psci --version
0.7.0.0
最佳答案
您不需要额外的功能。 String
的运行时表示只是一个字符串!
"use strict";
// module Test
exports.test = "A";
但是,test2
是正确的。 ->
的运行时表示是一个单参数 Javascript 函数,正如您已经拥有的那样。
关于javascript - 如何在 PureScript 中创建外部常量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31840087/