Skip to main content

# Getting started

Giving PureScript a try isn't too much of an afford. As PureScript completely runs on top of Node.js, all we need to do is installing the related NPM packages. Once it is installed, we can bootstrap a new project. Finally, we can compile to code to JavaScript. All of this happens on the basis of Node.js.

Installing PureScript on your machine:

npm install -g purescriptnpm install -g spago

Creating a new project: (Make sure to first create an empty directory, spago will set up in the current dir)

spago init

Running:

spago run

Building for the web:

spago bundle-app

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 -ynpm 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 initnpx spago runnpx 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 FP made easier book also serves as the original source of knowledge for this cheatsheet.