Reputation: 885
So I'm looking to play around with Purescript, but I haven't been able to get over this hump of actually setting up an enviornment to start playing in. Seems like most references on the subject are out of date at this point as well. Anyhow, I've tried a myriad of pulp init
-> bower install
-> pulp psci
and, although the steps leading up to psci
claim to work, importing the prelude or any other other basic modules fails. As such, psci
can't even recognize what the number "1" is. Also, the following error appears upon running pulp psci
Error found: at bower_components/purescript-lists/src/Data/List/ZipList.purs line 69, column 11 - line 69, column 11
Unable to parse module: unexpected "\n ZipList is not Bind. Any implementation would break the associativity law.\n\n Possible alternatives:\n Data.List.List\n Data.List.Lazy.List\n " expecting no indentation or end of input
See https://github.com/purescript/purescript/wiki/Error-Code-ErrorParsingModule for more information, or to contribute content related to this error.
Error found:
Unable to parse foreign module:
bower_components/purescript-foldable-traversable/src/Data/Foldable.js
See https://github.com/purescript/purescript/wiki/Error-Code-ErrorParsingFFIModule for more information, or to contribute content related to this error.
Upvotes: 4
Views: 964
Reputation: 4748
psc-package
is how you do it in 2019, don't use bower
or purs
.
You have some options:
To install the tools globally with npm
run this
npm i -g purescript psc-package
Then, create a new project
cd /tmp/my-new-awesome-purescript-project
psc-package init
psc-package install psci-support # so that the REPL works
You can now start a repl
psc-package repl
npm
!cd /tmp/my-awesome-npm-based-purescript-thing
npm init -y
npm install --save purescript psc-package
psc-package install psci-support
Then add this to your package.json
so that you can run the tools with npm run
:
"scripts": {
"build": "psc-package build",
"repl": "psc-package repl"
}
This has the advantage that you can have different versions per project and if you commit the package-lock.json
this is stored in repo.
Also users of your repository don't need to have purescript or psc-package installed as npm i
takes care of that.
Upvotes: 3
Reputation: 1253
So I actually just did this today on a new linux machine I set up hours ago. I hope it works for you.
First I installed nvm
to manage different node versions. I've read in various places that a few people have had issues with purescript not playing well with node v6, so I went with node v5. (This is purely anecdotal - I haven't run into such issues myself.) Anyway nvm
is not a bad idea in case you still run into issues; switching node versions might help.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm install 5
Then I used npm to install purescript, pulp, and bower.
npm install -g purescript
npm install -g pulp
npm install -g bower
Then I created a new directory for a purescript project. Then I used bower to install purescript-psci-support.
bower install purescript-psci-support --save
pulp psci
now works like a charm. And yes, it recognizes the number 1. :)
$ pulp psci
PSCi, version 0.9.3
Type :? for help
> 1
1
Hope this helps.
Upvotes: 2
Reputation: 4649
From the error message you have there it looks like the compiler version you have is out of date for the version of the libraries that are installed. The latest version is 0.9.3, and is available via npm
/ binaries are on GitHub / published on Hackage, etc.
Upvotes: 3