This is a copy of a spago issue. Copied for @hdgarrood
I’m using this setup https://github.com/purescript/spago#get-started-from-scratch-with-parcel-frontend-projects
And run npm run dev
.
The purescript manual says i should be able to execute shout(require('Prelude').showNumber)(42);
. This doesn’t work though. I tried instead console.log(require('../../output/Prelude'));
but this gave an empty object because there are no functions in the prelude javascript file
index.js in Prelude folder:
// Generated by purs version 0.13.6
"use strict";
module.exports = {};
Anyway what i really wanted to do is convert a Set into a List (because a Set structure is a pita to work with in JS). So i did let opt = require('../../output/Data.Set').toUnfoldable(mySet);
this works as it’s calling the right function. But it then crashes in this code.
From Data.List
var toUnfoldable = function (dictUnfoldable) {
return Data_Unfoldable.unfoldr(dictUnfoldable)(function (xs) { // <-- crash point
return Data_Functor.map(Data_Maybe.functorMaybe)(function (rec) {
return new Data_Tuple.Tuple(rec.head, rec.tail);
})(uncons(xs));
});
};
TypeError: Data_Unfoldable.unfoldr(...) is not a functionclient.e31bb0bc.js:16462:49
toUnfoldable http://localhost:1234/client.e31bb0bc.js:16462
toUnfoldable http://localhost:1234/client.e31bb0bc.js:23010
new http://localhost:1234/client.e31bb0bc.js:23319
handleAction http://localhost:1234/client.e31bb0bc.js:52021
$tco_loop http://localhost:1234/client.e31bb0bc.js:33695
toView http://localhost:1234/client.e31bb0bc.js:33719
go http://localhost:1234/client.e31bb0bc.js:34053
go http://localhost:1234/client.e31bb0bc.js:28850
go http://localhost:1234/client.e31bb0bc.js:28858
_run http://localhost:1234/client.e31bb0bc.js:24432
step http://localhost:1234/client.e31bb0bc.js:24510
drain http://localhost:1234/client.e31bb0bc.js:24268
enqueue http://localhost:1234/client.e31bb0bc.js:24291
step http://localhost:1234/client.e31bb0bc.js:24499
eventListener http://localhost:1234/client.e31bb0bc.js:29240
Data.Set.toUnfoldable looks like this
var toUnfoldable = function (dictUnfoldable) {
var $63 = Data_List.toUnfoldable(dictUnfoldable);
return function ($64) {
return $63(toList($64));
};
};
How must the project be setup so that the code in the output folder can use each other’s functions? And how can i use just require('Data.Set')
rather than working with relative paths?