Getting started with ReasonML
Table of contents for this series of posts: “What is ReasonML?”
In this blog post, I give tips for getting started with the programming language ReasonML.
There are two things to install:
reason-cli: Needed to support ReasonML in editors, but also contains various tools, including the interactive ReasonML command line
rtop. The installation is described in the ReasonML Guide. Editor support is provided by two parts:
- On one hand, a so-called language server provides services for working with ReasonML code.
- On the other hand, editor plugins and similar extension mechanisms communicate with the server to provide the actual support.
Quickly trying out ReasonML
The ReasonML online playground
The playground’s examples give you a first taste of the language.
rtop, the interactive ReasonML command line
rtop is an interactive command line for ReasonML and started via
rtop from a shell. Once it runs, interacting with it looks as follows.
Reason # 3 + 4;
- : int = 7
You can already see that everything has a static type in ReasonML. Don’t forget the semicolon at the end – it triggers evaluation! You can quit
rtop via Ctrl-D or via
There are two demo projects to get you started. They are created via
bsb (which is part of
Important tip: converting OCaml to ReasonML
Given that most material relevant for ReasonML uses OCaml’s syntax, it’s very useful to be able to convert from OCaml’s syntax to ReasonML’s. There are two ways of doing so:
- The online playground “Try Reason”.
- The tool
refmt (“ReasonML format”) that is part of
reason-cli. Get documentation via
More documentation on ReasonML
- The ReasonML Guide is very well written, but brief. It covers most of the language.
- OCaml’s manual complements ReasonML’s documentation, but is also terse.
- Real World OCaml (by Yaron Minsky, Jason Hickey, Anil Madhavapeddy) gives a more comprehensive introduction to OCaml.
- Awesome ReasonML is a page with ReasonML resources.