2015-02-12 66 views
2

我刚开始学习purescript后purescript by example,但我坚持在Chapter2 using grunt project templates结束。 我按照说明进行操作,但是当我运行繁重的命令,我得到这个错误:purescript入门

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

我发现通过挖掘到的代码是什么模块数学被导入到/output/Control.Monad.Eff.Random/index.js作为

var Math = require("Math"); 

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

如果我删除导入,让数学原生并运行主要index.js只需node index.js,一切工作正常。 我想知道是否有什么我可以做,以解决这个问题在purescript,或者如果它是我做错了。

+1

为什么是这个标签的[标签:哈斯克尔]?的确,PureScript与Haskell相关,而PureScript编译器是用Haskell编写的,但它们不是相同的语言。 – dfeuer 2015-02-12 04:31:20

+0

我现在删除了haskell标签,我最初添加它是因为其他一些purescript问题正在使用该组合。 – 2015-02-12 04:42:23

回答

4

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

作为一种变通方法,你应该能够在你的bower.json文件中指定的purescript-random以前的版本,或者在命令行上:

bower install purescript-random#0.1.1 
+0

太棒了菲尔,非常感谢你:)期待着尽快开始在生产代码中使用PureScript – 2015-02-12 04:41:10