I just started learning purescript following purescript by example but I am stuck at the end of Chapter2 using grunt project templates. I follow the instructions, but when I run the grunt command I get this error:
/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
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.
I was wondering if there is something I can do to fix this in purescript, or if it is something I am doing wrong.