Reason on OCaml 4.06

announce

#1

The Reason syntax is now available on OCaml 4.06!

Thanks to github users @hcarty , @rgrinberg @ncihnegn, @hhugo, @avsm for some input/feedback and/or helping to merge into opam-repository.

Thanks to @let-def for nearly single-handedly implementing the latest iteration of Reason syntax changes which were intentionally designed to be more familiar to the largest developer audience (with ES6 style lambdas arguments => returnValue). Whether or not we all personally like the syntax changes, it’s undeniable that the feedback we’ve received has been overwhelmingly positive. I hope this ends up being good for the growth of the OCaml ecosystem in the long term. Several people have approached me asking how they can “use Reason to build their app” now that the “syntax is improved”. The power that syntax has over perception of a language continues to be eye opening. Even as a fan of the ML style of syntax, I must say it feels great to have a larger number of people immediately recognize your code as familiar and embrace it.

It should be fairly straightforward to integrate the Reason syntax/printer into your application, and Reason shouldn’t prohibit you from accessing all of OCaml’s features (anything less is currently considered a bug - for which pull requests (or Issues) are graciously welcome). If you use jbuilder, then your build system already supports Reason (thanks to @diml and @rgrinberg). Merlin already has built-in first-class support for using Reason or standard OCaml syntax. (It’s pretty cool how Merlin + Reason demonstrates that you can build IDE infrastructure for which concrete syntax is fully abstracted away without giving up recovered parsing and recovered type checking). For those curious, Reason uses ocaml-migrate-parsetree in order to sustain support for all modern OCaml versions. (Reason was one of the first test cases for ocaml-migrate-parsetree).

There’s still some room for improvements with the workflow/packaging and your contributions to help improve it are always welcomed. For example, rtop (the utop top level for Reason) should be factored out into its own opam package (this is tough to orchestrate with opam-publish). This will help reduce package manager conflicts.

Most of our work in the last six months has been focused around building and shipping Reason React which uses Reason, BuckleScript, and ReactJS to create a very nice UI development experience (okay, to say I’m biased would be putting it lightly). (Questions about Reason React or BuckleScript would be best asked in their own threads, thanks!)

Stay tuned for more syntax improvements/features. Again, your contributions are welcomed and appreciated.


#2

Congratulations on shipping this! I’m looking forward to finally learning frontend programming via Reason React :slight_smile:


#3

Nice work @jordwalke & contributors!

One thing I’m a bit confused about with regards to the overlap of OCaml and Reason ecosystems is interoperability. To what extent will it be possible to leverage Reason dependencies in OCaml and vice versa?

From what I understand Reason is Ocaml and that the language is really pretty much the same, still there seem to be some significant differences in tooling (e.g. npm vs opam, bsb vs jbuild) which appear to separate those two ecosystems?

(Disclaimer: I’m new to OCaml / Reason)


#4

Hi, Reason targets OCaml bytecode/native runtimes through the regular OCaml compilers, ocaml/ocamlopt, and it also targets JavaScript through the BuckleScript compiler. Whichever runtime you’re targeting, Reason is very well-integrated with its toolchain. So e.g. for bytecode/native you would use opam/jbuilder as you would for an OCaml syntax project, and for BuckleScript you would use bsb, the BuckleScript build tool, just as you would for BuckleScript with OCaml syntax.


#5

Can we have the Haskell syntax for OCaml now? :blush: