Welcome to the annual ‘Recommended Tooling for PureScript’ post! You can see previous years here:
- Recommended tooling for PureScript in 2021
- Recommended tooling for PureScript in 2020
- Recommended tooling for PureScript in 2019
There are two notable new tools for PureScript this year:
purescript-backend-optimizeris a new optimizing backend toolkit for PureScript, which ships with its own ECMAScript code generator that generates more readable, modern code than the compiler. It produces code up to 35% faster and 25% smaller than the
purscompiler alone. Development was lead by @natefaubion.
- The PureScript Registry entered alpha this year. It stores PureScript packages and metadata about them, produces package sets, and provides a library to help authors of package managers integrate with the various registry components. The PureScript registry is a replacement for the Bower registry and offers much better support for publishing PureScript packages. When you publish your package to the PureScript Registry its documentation is uploaded to Pursuit and it is added to the day’s package sets release automatically.
vite, and other dev tools that require ES modules. Notably,
esbuild. This is good news: bundle sizes are about 25% smaller with the new compiler output +
As usual, you can see examples of the tools I recommend in action in these repositories:
- Real World Halogen by @thomashoneyman, which demonstrates PureScript using the Halogen UI library.
- Real World PureScript React by @jonas, which is the same project as Real World Halogen, except written using React bindings.
- The PureScript Cookbook by @jordanmartinez, @ptrfrncsmrph, @milesfrain and others, which demonstrates how to write common snippets of PureScript code.
Real World PureScript Payload by @jim, which demonstrates PureScript on the backend with the
- Halogen Extended Template by @and-pete, which builds on the default Halogen template with common libraries used in Halogen apps.
You can install PureScript tools (like
purs) either system-wide or in a particular project using one or more methods, listed in order of popularity:
- Use a package manager that uses the NPM registry, such as
- Use the Nix package manager via
If you use GitHub Actions, then you can use the
setup-purescript GitHub Action to set up a PureScript toolchain on Windows, macOS, or Linux in your workflow.
If you are starting a new project in PureScript today, you will need at minimum:
purs, the compiler. Spago uses
pursunder the hood to compile your code, start an interactive repl, and so on. The compiler also provides an IDE server for editors to use.
spago, the build tool and package manager for PureScript. It’s used to install PureScript libraries, build PureScript code, and generate documentation.
If you are building an application for the browser, you will also need:
esbuildto bundle your code when you run
spago bundle-app, if
While not necessary, these tools are also useful in many projects:
purs-tidyis by far the most popular code formatter for PureScript.
psais a configurable error-reporting frontend for the compiler. It lets you control reporting for errors and warnings. Spago automatically uses
psaif it is available in your PATH.
pscidis a /fast/ file watcher that reports errors and suggestions in the shell. It’s essentially the same as the error reporting provided by your editor, but can often be faster.
purescript-backend-optimizeris an optimizing backend toolkit for PureScript, which produces code up to 35% faster and 25% smaller than
pursalone. It should be used when bundling PureScript for production.
pnpm. I recommend using NPM.
esbuild. I recommend
esbuildfor simple projects and
webpackfor more complex ones.
- You may also want to use a linter like
The PureScript compiler has an IDE server included, which has been used to implement a PureScript language server that major editors can use. Some of the features that PureScript’s IDE tooling supports include:
- Auto-completion, definitions & documentation on hover, and jump-to-definition
- Automatically fix imports, missing types, and other compiler errors / warnings
- Fast rebuilds on file save
- …many more!
Most folks I know writing PureScript use:
- VSCode with
- Vim with
psc-ide-vimor a LSP plugin.
- Emacs with
psc-ide-emacsor a LSP plugin
If you are authoring a library that you plan to publish to the PureScript Registry, with documentation published to Pursuit, then you have historically been forced to use the Bower package manager and Pulp build tool instead of Spago. While you can continue to use these tools, you no longer have to. Now that the registry is in alpha you can publish Spago projects so long as all of your dependencies point to valid SemVer Git tags (and not, for example, to a branch like
main or a particular commit).
To learn more, please see the registry alpha announcement:
I’ve kept the post nice and short this year! If you have any suggestions for other notable new tools or example projects using these tools that I should include, please let me know and I can edit the post. Thanks for reading!