This release should be used in conjunction with bs-platform 4.0.3.
We recently had our very first Reason Conf last May! Videos are available on Youtube, if you haven't seen them yet. In short, it was a massive success; big, belated thanks to @ryyppy, @nikgraf and @okonetchnikov. This is truly a conference by the community, for the community.
That being said, we've heard your feedback during the conference loudly and clearly. This Reason release addresses most of those feedback! Special thanks to @anmonteiro and @iwanKaramazow for many of these fixes.
See the changes here. No breaking changes; nothing but an avalanche of quality-of-life improvements. Hopefully you'd notice many subtle tweaks in your day-to-day development.
We've made a new, corresponding ReasonReact release too. Get it while it's hot!
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");
moduleVenue = {
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 = 1let 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.
Our community member @astrada has helped us integrate ReasonReact's JSX and (runtime) library support into this site's Try page! It wasn't a small feat, so thank you @astrada.
Now you can try any ReasonReact snippet in the playground and things should Just Work. If you ever need a convenient ReasonReact template, there's one in the Examples menu.
Special shout-out to this version, as it fixes many bugs and comes with some long awaited features. As always, the changes are in HISTORY.md. Special highlights:
New pipe sugar allows inserting argument at arbitrary position: [1, 2, 3] |> map(_, a => a + 1) |> keep(_, a => a === 2). Basically ES2030.
Tired of seeing [@bs] foo(bar, baz) for uncurrying? Use the new version to refmt your code to automatically format it into foo(. bar, baz)!
Trailing comma for everything, final function body item now formats to a trailing semicolon, let%foo extension sugar, fixes for comments, JSX, etc.
Get the new version through reason-cli and through BuckleScript's bs-platform 2.2.2. Have fun!
Happy belated new year! Our current reasonml Discord has held up well to the influx of newcomers until now, but it's getting gradually harder for us to go through every message every day. We've therefore decided to open up a more permanent communication medium: Reason Forum.
We're still on our real-time Discord chat, but the addition of a forum should alleviate our maintenance a bit, thanks to the deduping of newcomer questions and turning sync Discord chat into long-term async discussions. We maintain another permanent medium, Stack Overflow, but general discussions and announcements never really belonged there.
You don't have to register a new account; existing Github logins work. Big thanks to Brent Vatne for helping us set up everything!
Enjoy, and here's to an even better year for the Reason and BuckleScript community =)
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, thatMerlin), 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.
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!
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.
Messenger.com is the web version of Facebook Messenger; we also share code with facebook.com's inbox view and chat tabs. For over a year, the Reason team has been working directly on Messenger in order to integrate Reason + BuckleScript into the codebases. As of a while ago, we've reached 50% Reason code coverage!
Some Statistics
Full rebuild of the Reason part of the codebase is ~2s (a few hundreds of files), incremental build (the norm) is <100ms on average. The BuckleScript author estimates that the build system should scale to a few hundred thousands files in the current condition.
Messenger used to receive bugs reports on a daily basis; since the introduction of Reason, there have been a total of 10 bugs (that's during the whole year, not per week)! *
Most of the messenger core team's new features are now developed in Reason.
Dozens of massive refactors while iterating on ReasonReact. Refactoring speed went from days to hours to dozens of minutes. I don't think we've caused more than a few bugs during the process (counted toward the total number of bugs).
Everyone writing Reason got promoted for quality engineering. Just kidding. But definitely high, long-term impact.
* in the Reason sections. This excludes: the JS sections, the backend (still PHP), etc.
Which Team's Next?
We believe in iterating on/alongside product teams in order to create the best infra. The product teams' and open source folks' feedback has changed our strategy a few times, for the better. As of today, Reason and BuckleScript are also deployed on a WhatsApp internal tool, Instagram Web (small scale), plus some critical Ads internal tools. We'll be working closely with these teams over the next year.
We've successfully onboarded regular JavaScript folks to Reason; in the most extreme case, an intern with no JS knowledge was able to ship ReasonReact code in production (and made 0 bug while doing so). Give your own team a try! =)
A big thanks to all these teams' members, to Hongbo (BuckleScript author) and to the OCaml community (really, 50% Reason means 50% OCaml. We're nothing without you); and of course, to all of you folks in the community for being with us all this time. The best is yet to come.
Sometimes when I'm busy working, some random colleague/Discord member would ping me and tell me "Yo Cheng Lou why are Reason's errors so bad? Why can't you be more like Elm Cheng Lou? Why? Look at how great Elm's errors are Cheng Lou, look."
In reality I'm pretty darn ashamed of our error messages; here we are, a type system with two decades of solid research and implementation, but sometimes presented to the end users as if it's something that'd get in their way.
No more! We've heard you loud and clear, and delivered you much improved error messages! A few things we did:
Display the error-ing line(s), right inside the terminal.
Better colors, for quicker visual search.
Improved messages in many cases.
Errors in Reason syntax for Reason files.
A bit of breathing room between lines.
The last point is a tradeoff; errors end up taking more space. Seeing that you'd usually focus on a single error rather than trying to get an overview of all errors, we've deemed this tradeoff worthwhile, especially in the context of a big amount of build output. Considering the new warning format:
Here's the same warning, old version, buried among other outputs:
At Messenger, we've seen people ship warnings to production not because they didn't want to fix them, but because they've missed them! It's not rocket science. Leave some negative space here and there. Color things appropriately. Voilà!
The new errors can be turned on by adding "bsc-flags": ["-bs-super-errors"] to your bsconfig.json, like so. They're also available for bsb-native. True to our stack's spirit, they're fast, simple to configure, and solid.
One more thing: we're vertically integrated common pitfalls of ReasonReact into these messages too, when applicable.
This is just the first of many iterations to come! Got a message you'd like to see explained better? File an issue here!
The new documentation website is built by our community member Jared (make sure to check his Reason blog posts too!). The new site keeps most of the same content from the old one, while providing a better structure to navigate through them. You'll notice "Suggest an edit" links all over the place. Take a look around!