Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a Purescript Enviornment

Tags:

purescript

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.

like image 858
Tshimanga Avatar asked Feb 07 '23 09:02

Tshimanga


2 Answers

psc-package is how you do it in 2019, don't use bower or purs.

You have some options:

  1. install tools globally
  2. install tools locally (per project)

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

Notes

  • You don't have to use npm!
  • You can use npm and don't install globally:
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.

like image 125
wires Avatar answered Feb 17 '23 03:02

wires


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.

like image 27
gb. Avatar answered Feb 17 '23 02:02

gb.