Exploring ReasonML
Please support this book: buy it or donate
(Ad, please don’t block.)

3 Getting started with ReasonML

In this chapter, I give tips for getting started with the programming language ReasonML.

3.1 Installation

There are two things to install:

3.2 Quickly trying out ReasonML

3.2.1 The ReasonML online playground

The ReasonML website contains an online playground that is very useful for seeing how the language works and what the corresponding JavaScript and OCaml code is. It can also convert from OCaml to ReasonML (more on that later).

The playground’s examples give you a first taste of the language.

3.2.2 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 #quit;

3.3 Template projects

There are two template projects to get you started. They are created via bsb (which is part of bs-platform):

3.4 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: