Some cut down trees

In November, Dark made a decision to move off of Elm, and port our frontend to Bucklescript (aka OCaml, dba ReasonML). Being over 10kLOC, and having active development, it would have been error prone and difficult to port it manually. Instead, we wrote an Elm-to-OCaml compiler to translate it semi-automatically, and then worked to get it over the line manually.

Philip2 (pronounced fee-leap-the-second) is our compiler from Elm to Bucklescript. It parses Elm using elm-format, translates that into the OCaml abstract syntax tree, then uses the OCaml compiler to print out OCaml. We specifically target Bucklescript, and the result plays very nicely with bucklescript-tea, an Elm Architecture for Bucklescript.

Bucklescript translates OCaml to Javascript, and is commonly used in the ReasonML ecosystem. Since Elm is mostly a subset of OCaml — though with a different syntax — it was fairly straightforward to translate it.

The conversion using philip2 removed several weeks of grunt-work to convert the code over to Bucklescript. It still took several weeks of engineering time to finish the conversion, including:

Porting much of the Elm standard library to Bucklescript (our port is available).

Making minor bug fixes to bucklescript-tea.

We have a guide to help you port your project, and we will accept contributions to make the process easier and more automated. Using our tools should shave a few weeks off the translation.

We hope this tool will be useful for people looking for an exit strategy from Elm, as well as those looking to try out Elm and worried about it not working out.

Try it!