A quick overview of Purescript package managers as of October 2018


In this post I want to give a very quick overview of Purescript’s package managers and some tools related to them.

I’ll go through:

  • bower
  • psc-package
  • spacchetti
  • spacchetti-cli

Bower

Coming from the JavaScript world, Bower is certainly the most familiar to use. It’s the default package manager used with pulp init, and all the familiar usual commands work, e.g.

mkdir foo
cd foo
pulp init
bower i
bower i --save purescript-simple-json
bower i --save-dev purescript-quickcheck

Sadly, Bower is not the perfect tool to use with Purescript, and I realized this mainly during the switch from Purescript v0.11 to v0.12. Figuring out the correct packages versions that have to go with the compiler version currently in use can get annoying and a source of many mistakes.

Luckily, I found out that this problem was already solved by psc-package!

It’s important to note that currenly using bower for dependencies is the only way to publish a package on Pursuit.

Psc-package

Psc-package uses package sets to manage dependencies. This means that we don’t have to worry too much about matching versions. We can just pick the right set, and then happily install all the packages we need!

pulp --psc-package init
psc-package install
psc-package install simple-json

There’s a nice bonus in that we can drop the prefix purescript- from packages names too!

I’m not going to write more about it, as there’s already a nice guide.

Sadly, not even psc-package is perfect: using packages that are not included in the default sets requires some work. Basically the package-sets repository has to be forked and then modified together with a new tag. Then this new set can be used in our projects.

Spacchetti

Spacchetti brings the power of Dhall (a programmable configuration language) to improve the psc-package experience. Two of the problems of extending psc-package’s package sets are having to deal with manually editing a large JSON file, and some messy and not very useful git diffs.

Spachetti is an alternate psc-package package set, but with super powers. The JSON is generated using Dhall, and there are a few scripts to automate some tasks, e.g. one is used to add a package from bower, by generating automatically the correct JSON object with all the dependencies.

The workflow to add packages is essentially the same as with psc-package: fork spacchetti’s repo, make the changes you need, add a tag, and then use it in your project.

There’s a very nice guide that you can read to learn more.

Spacchetti-cli

Spacchetti-cli is a new tool which adds some functionalities to spacchetti, and has the potential to make our life even easier.

Right now it only has two commands: local-setup and insdhall (ugh).

With these it becomes very easy to add additional packages to a spacchetti set without having to go through all the procedure of forking, modifying etc.

We can just define the base set and the eventual changes or additions we want, and spacchetti-cli will think about everything else (well, almost).

You can read more about it here.

Related Posts

Resizing and moving windows in Doom Emacs

Setting up TabNine on Doom Emacs

The correct docker-compose setup for Wordpress and Nginx

Adding a newline after a comment block in Doom Emacs

PureScript Date and Time guide

Adding live css and js reload to Yesod

Optional elements and properties in Halogen

Simple AJAX in Purescript

Automatically adding (or removing) a prefix to a record labels in Purescript

Adding static files to Yesod