Index | Tutorial 1 > Tutorial 21 >>
If you’re new to FP or you haven’t tackled Brian’s course, then I highly recommend that you do that first (I certainly did, and it helped me a lot). Then, once you understand the basic 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 head first 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. You will also find the accompanying tutorial markdown (e.g., tut01/README.md) 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 run all then
npm run execfrom there on. 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, this assumes you have (and you should) the
npmpackage manager installed. These scripts depend on
rimraf (the UNIX command `rm -rf` for node),
Pulp (a build tool for PureScript projects),
Psc-Package (PureScript package manager), and the
Bower package manager. Note that Bower is used in a couple of cases only. I will remove it, once Psc-Package captures all my module dependencies. All this is explained below.
You can skip this section if you’ve already installed and are using version 0.12.x of PureScript on your computer.
In earlier versions of this tutorial, I recommended you use Bower as your package manager. In fact, this is recommendation given in Getting Started with PureScript. Bower is useful, thanks to its flat dependency graph, and easy to use. However, its inability to restrict libraries that work with a specific compiler version of PureScript can cause problems for beginners. Especially during the early stages of a release of the compiler when libraries, tooling, and documentation are still catching up.
Instead, I recommend you use PureScript’s own
psc-packagemanager. The installation and usage are just as simple using Bower, so I see no good reason to use Bower when it is not necessary. Assuming you already have npm running on your machine, here’s how to install PureScript, Pulp, Psc-Package, Bower, and rimraf. As of this writing, I recommend you use the 0.12.2 version of the compiler. Before executing the following command, be sure you have the latest npm package manager and node installed.
npm i -g email@example.com pulp psc-package bower rimraf
You can check that these work by trying some commands:
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.
Assuming you’ve installed PureScript, Pulp, and Psc-Package, then it doesn’t get any easier than this to start your adventure in functional programming with PureScript:
$ mkdir purescript-hello
$ cd purescript-hello
$ pulp --psc-package init
$ pulp run
Pulp is an excellent build tool with plenty of helper options; such as watching for source file updates and re-compiling them automatically. As you add more library dependencies to your program, you can install them with
psc-package install <package-name>). You’ll find more information on
I’ll add additional links as I write the tutorials. But If you would like to look ahead then most of the code samples from Brian’s videos have been ported to PureScript already and are available on Github. But I may amend them as I write the accompanying tutorial.
Create your free account to unlock your custom reading experience.