开始使用纯脚本

Getting started with purescript

我刚开始学习纯脚本purescript by example but I am stuck at the end of Chapter2 using grunt project templates。 我按照说明进行操作,但是当我 运行 g运行t 命令时,我收到此错误:

/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.

我通过深入研究代码发现模块 Math 被导入 /output/Control.Monad.Eff.Random/index.js 作为

var Math = require("Math");

function random() {
    return Math.random();
}
;

如果我删除导入,让 Math 成为原生的并且 运行 将主要 index.js 简单地与 node index.js 连接,一切正常。 我想知道我是否可以在纯脚本中做些什么来解决这个问题,或者这是我做错了什么。

purescript-random 模块在与 psc-make 一起使用时在最新版本中损坏。它将在下一个版本 0.6.7 中通过编译器补丁修复,希望是在本周。

作为解决方法,您应该能够在 bower.json 文件或命令行中指定 purescript-random 的先前版本:

bower install purescript-random#0.1.1