Navigating your way
If you're new to FP or you haven't tackled Brian's course, then I highly recommend that first (I certainly did, and it helped me a lot). Then, once you understand the fundamental abstractions, come back, and I'll show you them in PureScript. I've done my best to explain the concepts, but Brian is a master at teaching them. Also, these tutorials are not a replacement for a good old fashioned PureScript primer. So take the time to learn a little PureScript syntax before diving headfirst into these tutorials.
Each tutorial has been placed in a separate folder named 'tut##', where ## is a number (e.g., 'tut01') that corresponds to video## from Brian's course. There is the accompanying tutorial markdown (e.g., tut01/README.md)here, which illustrates the abstraction from Brian's corresponding video (e.g., video1) and how to implement it in PureScript.
I have set up the folders so that you can run the PureScript code samples for the first time with
npm install which installs spago and purescript as dependencies. Then type
npm run all which will compile and run the source code. Thereafter, type
npm run exec to run it again. There's also individual scripts
npm run clean,
npm run install,
npm run build, and
npm run exec; used to clean, install, build, and execute the tutorial examples respectively.
Naturally, all this assumes you have the
npm package manager installed. These scripts also depend on
rimraf (the UNIX command
rm -rf for node), and
Spago (PureScript's package manager and build tool). I explain all of this below.
The PureScript community has now settled on the Spago package manager and build tool. Spago is the recommendation given in Getting Started with PureScript, which I recommend you read thoroughly before proceeding further. In my experience so far, Spago is a welcome addition to PureScript's tooling, providing a great UX, with minimal dependencies and reproducible builds.
Get up and running in PureScript
package.json file in each of the tutorials includes
purescript as dev dependencies. Therefore, there is no need to install them globally. At the time of this tutorial revision, the latest npm version of Spago is
0.20.3 and PureScript is
Install editor plugins
There are plugins for most editors to support syntax highlighting, build support, REPL (Read, Evaluate, Print, Loop), and autocomplete. You'll find the information to install these plugins for your favorite editor here.
Run your first PureScript program
" $ mkdir purescript-hello $ cd purescript-hello $ npm install -D spago purescript $ spago init $ spago build $ spago run "
My Favorite PureScript tools & references
- PureScript by Example is the official PureScript book, originally by Phil Freeman (the author of the PureScript language) and now maintained by the community fork.
- Pursuit is the home of PureScript documentation; soon to become your best friend
- Try PureScript allows you to try key examples of PureScript in the browser. You can also create your own.
- psc-ide (distributed with the compiler) provides editor support, including atom, emacs, vim, and visual studio
- Discourse for discussing PureScript.
- FP Slack has a #purescript and #purescript-beginners channel.
I'll add additional links as I write the tutorials. But If you would like to look ahead, then the majority of the code samples from Brian's videos are available on Github. But I may amend them as I write the accompanying tutorial markdown.
Edited on August 14, 2021, bumping to Spago 0.20.3 & PureScript 0.14.3, and removing references to Bower