简体   繁体   English

purescript入门

[英]Getting started with purescript

I just started learning purescript following purescript by example but I am stuck at the end of Chapter2 using grunt project templates . 我只是通过示例跟随纯脚本开始学习purescript 但是使用grunt项目模板将我困在第二的结尾。 I follow the instructions, but when I run the grunt command I get this error: 我遵循了说明,但是当我运行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.

What I discovered by digging into the code is that the module Math gets imported into /output/Control.Monad.Eff.Random/index.js as 我通过深入研究代码发现,模块Math被导入为/output/Control.Monad.Eff.Random/index.js作为

var Math = require("Math");

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

If I remove the import, letting Math being native and running the main index.js simply with node index.js , everything works fine. 如果我删除了进口,让数学成为本土和运行主index.js简单地与node index.js ,一切工作正常。 I was wondering if there is something I can do to fix this in purescript, or if it is something I am doing wrong. 我想知道是否有什么办法可以解决此问题,或者我做错了什么。

The purescript-random module is broken in the latest release when used with psc-make . 当与psc-make一起使用时, purescript-random模块在最新版本中已损坏。 It will be fixed by a compiler patch in the next release, 0.6.7, hopefully this week. 希望在本周的下一个版本0.6.7中通过编译器补丁对其进行修复。

As a workaround, you should be able to specify the previous version of purescript-random in your bower.json file, or on the command line: 解决方法是,您应该能够在bower.json文件中或在命令行上指定purescript-random的先前版本:

bower install purescript-random#0.1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM