ANN: dovetail - a PureScript interpreter

I’ve been working on this project for the past few months, and thought people might find it interesting and hopefully useful. The goal is to reuse the front-end of the PureScript compiler to build DSLs in Haskell.


What are the advantages of doing this over just using Haskell to build DSLs in Haskell? Ergonomics, or is there something more?

1 Like

Well assuming what you want is a DSL which looks like PureScript, which is the use case Dovetail is built for, then you could use Dovetail, reusing all of the front end features of the PureScript compiler for free, or you could build the whole compiler front-end yourself.


Here’s my mental modal of how a language works (at a very high level, as I’ve never worked on one myself).

A language has two parts. A syntax and a semantics. You can separately break down syntax into an abstract (or more abstract) and concrete syntax. In the same vein, your semantics can be more formal (perhaps built from some logical axioms) or less formal (a hand-wavy description about what should happen or what something means).

One of PureScript’s highlights (as I understand it!) is that it has a clean separation between front-end and back-end. That is, you can target different back-ends with relative ease. When somebody says they’re re-using the PureScript’s front-end, that’s what I take it to mean.

There are two things I’m not sure about:

  1. The first is a bit of a segue, but should I consider a different PureScript backends as having the same or just similar semantics to PureScript with the JavaSscript back-end? (Is there a separate formal/formal-ish semantics?)
  2. Where does, if at all, Dovetail fit here?

There is no formal semantics for PureScript because there is no (AFAIK) spec. That means that any alternate backend is free to do anything - change from strict to lazy, remove purity, whatever. I’d very much like to see a specification for the semantics of PureScript and its core libraries, and maybe even something like Dovetail could encourage the development of that. However, I don’t know if any of the maintainers are interested in creating a specification or not. I’d be happy to get involved, but I’d want to make sure it’d be supported.

As for Dovetail, it tries to stay close to the PureScript JS semantics, including strict evaluation. The devil is in the details though, and getting a perfect simulation of the JS backend is unlikely any time soon. At some point soon, I will try to document all of the rough edges I’ve run into while implementing the library so far.