Mim*_*imo 2 functional-programming ffi purescript
我刚刚开始通过示例学习purescript ,但是我在第2章的末尾使用了grunt项目模板.我按照说明操作,但是当我运行grunt命令时,我收到此错误:
/Users/chad/playground/purescript/tests/tmp/node_modules/Control.Monad.Eff.Random/index.js:8
return Math.random();
^
TypeError: undefined is not a function
at Object.random (/Users/chad/playground/purescript/tests/tmp/node_modules/Control.Monad.Eff.Random/index.js:8:17)
at __do (/Users/chad/playground/purescript/tests/tmp/node_modules/Test.QuickCheck/index.js:177:52)
at Object.__do (/Users/chad/playground/purescript/tests/tmp/node_modules/Main/index.js:19:201)
at Object.<anonymous> (/Users/chad/playground/purescript/tests/tmp/index.js:1:79)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
Warning: -> error 1 /Users/chad/playground/purescript/tests/tmp/index.js (125ms) Use --force to continue.
Aborted due to warnings.
Run Code Online (Sandbox Code Playgroud)
我通过深入研究代码发现,模块Math被导入为/output/Control.Monad.Eff.Random/index.jsas
var Math = require("Math");
function random() {
return Math.random();
}
;
Run Code Online (Sandbox Code Playgroud)
如果我删除导入,让Math是原生的并且index.js简单地运行main node index.js,一切正常.我想知道是否有什么我可以做的来解决这个问题,或者如果我做错了.
使用时,purescript-random模块在最新版本中被破坏psc-make.它将在下一版本0.6.7中由编译器补丁修复,希望本周.
作为解决方法,您应该能够purescript-random在bower.json文件中或在命令行上指定以前的版本:
bower install purescript-random#0.1.1
Run Code Online (Sandbox Code Playgroud)