Syntax ยท May 25, 2018

Announcing Reason 3.2.0

Cheng Lou
Core Team Member

New Syntax Release

This release should be used in conjunction with bs-platform 3.1.4.

Rejoice! The release you've all been waiting for. This fixes bring three major quality-of-life improvements when using Reason's formatter, refmt.

Whitespace Tuning

Your empty lines will now be preserved when you format your code! Multiple lines still collapse into one in most cases.

This also mean that those awkward, forced new lines refmt previously inserted between e.g. top-level statements are now gone too (unless you insert them yourself). Here's an example snippet where whitespaces are preserved as-is:

let confName = "Reason Conf"; let month = "May"; let year = "2018"; let location = Some("Vienna"); module Venue = { let secretCode = c => switch (c) { | 0 => "Turn on the mic" | 1 => "Turn off the mic" | 3 => "Start the slides" | _ => "Talk to organizer" }; /* important, grouped let statements */ let venuePassword = 123; let contact = ["ryyppy", "nikgraf", "okonetchnikov"]; };

This change was very complex to implement; please thank Iwan, our refmt expert.

Semicolon Relaxation

Ever gotten those cryptic syntax errors when you write this?

let a = 1 let b = 2

We now gracefully accept this! No more semicolon syntax errors.

However, for good measure, refmt will still print it into:

let a = 1; let b = 2;

Because we're hesitant to recommend the former for now. Under the current syntax, some semicolons are still hard to remove completely. We'll keep working on this; in the meantime, do write in the latter style. If you forget a semicolon, refmt will add it back.

This improvement is made by Fred (Merlin, Reason 3, and many others). Another very challenging change.

Unicode String Printing

let message = "Hi! Unicode formats correctly now. Sorry for the wait ๐Ÿ˜…"

Note that to compile to the correct unicode string to JavaScript, you'd still need to use BuckleScript's {js|foo|js} interpolation feature. We'll try to unify the effort here.

Again, by Fred. Thanks!

As always, full list of changes here. Enjoy!

This article was originally released on
Want to read more?
Back to Overview