Installing PureScript on your machine:
npm install -g purescript
npm install -g spago
Creating a new project: (Make sure to first create an empty directory, spago will set up in the current dir)
Building for the web:
Getting started the recommended way
This way avoids a global installation of PureScript to ensure working with multiple projects in different versions.
(Make sure to first create an empty directory, spago will set up in the current dir)
npm init -y
npm install --save-dev spago purescript
# to check whether installation works:
npx spago version
As you can see, using NPM like this only installs Spago and PureScript locally, for development - bound to your project.
Then, using NPX you can initialise the PureScript project just like before:
npx spago init
npx spago run
npx spago run
You can start the REPL with "spago repl".
You can import any module from the src-directory with: "import Module" For example, "import Main".
From now on, you can access data written in the file in the REPL. Whenever you change something in the file, make sure to reload the REPL: ":reload".
To quit: ":quit".
Getting the type of some data: ":type data"
Great ressources for PureScript
- The official PureScript book
- Jordan's notes
- Functional Programming Made Easier - Book. There is a free sample which is awesome
The FP made easier book also serves as the original source of knowledge for this cheatsheet.