Syntax · Oct 27, 2017

Announcing Reason 3.0

Cheng Lou
Core Team Member

I'm writing this post while coincidentally sitting next to the Reason team manager's manager who's trying out the new Reason syntax; his first impression is "this is exactly how I think it works!". I think this alone made all our effort worthwhile.

Reason 3 is primarily the work of Fred, the maintainer of Merlin (yeah, that Merlin), Iwan and Jared, over the last six months. The release packs a lot of infra changes under the hood, most of which, we hope, stay invisible to you and occasionally make you feel "yeah, that is how I think it should work".

The infra changes wouldn't have happened without a tight cooperation from these OCaml and JavaScript folks. We're really, really grateful for all the support we've gotten. Thank you so much.

Highlights:

  • Here's how it looks.

  • 100+ parsing & printing issues fixed! The total open issues count went from almost 500 to <300.

  • New error messages infra, by Fred. This solves lots of existing pain points with refmt error report: reserved keywords, missing semicolon, etc. More coming soon! Please do give Fred a shout out on his Twitter. Show that the JavaScript folks appreciate his help.

  • Unification of [@foo], [@@foo] and [@@@foo] into [@foo]. Labeled argument + type punning, JS object type sugar {. "foo": string}, string concat is now ++, infix operators formatting tweaks, etc.

  • We've now exposed dedicated APIs for programmatic usage of the Reason parser and printer, refmt, for both native and web usage. In particular, the web version of refmt powers Klipse, reason-tools, the Reason docs site, etc. If you're coming from JavaScript: npm install --save reason to get the single refmt.js script. It gzips to <350kb, so go wild and impress us with your refmt usages!*

  • Aaaand yes, JS application/abstraction syntax (aka, parentheses around functions/parametrized types). Yes, you still get automatic currying; it's a pure syntactical change. Honestly, this point alone deserves its own post, but it opens the floodgates of bikeshedding, so we're gonna refrain from writing one and will just watch you folks argue over this on Twitter (and pick the most creative rants and hang them on our wall!). More seriously, if you deeply care about syntax, then instead of shouting about the change publicly, voice your feedbacks/complains privately to @_chenglou and @jordwalke. If you don't care about syntax, then great!

How do I get it?

  • There's a migration script here. Use it. No manual syntax upgrade needed.

  • Uninstall & upgrade your editor tooling to 3.0.0 (instead of the old 1.13.7), for editor tooling.

  • Upgrade your project's BuckleScript to 2.1.0.

  • Set "refmt": 3 in your bsconfig.json.

  • Restart your editor.

  • If you're working on native, it's reason.3.0.0 on OPAM.

How does this affect existing projects?

  • If you don't specify "refmt": 3 in your bsconfig.json, nothing changes. (Update: bs-platform 2.1.0 now defaults to refmt 3. If you want to keep refmt 2, put "refmt": 2).

  • Your third-party dependencies can still stay at version 2, vice-versa. Things will work as intended.

  • Learning the new syntax? Reason-tools now converts between syntaxes too!

  • For native, the dependencies will have to upgrade the syntax first. We'll solve this better in the future.

Voilà!

To see the full list of the changes, please go to HISTORY.md. Again, check the migration script so that you don't go and manually convert each file.

Thank you again, Fred, Iwan, Jared and all the others (hcarty, Sean, Jordan, Cristiano, Hongbo, Ricky, Andrey, etc.) for the whole effort.

* If you format your own blog site's Reason code using it, the post's syntax can potentially stay always up-to-date without you needing to go and manually update the snippets. And yes, we have some crazy ideas around this soon.

This article was originally released on https://reasonml.github.io/blog/2017/10/27/reason3
Want to read more?
Back to Overview