Skip to content

Guide · Open source

How to use Reason: install, build and run the tests

Updated · written with AI from the project's own documentation and checked against our catalogue data

Reason is a programming toolchain built on OCaml. It offers a different syntax, closer to JavaScript, for writing type-safe code that works with both the JavaScript and OCaml ecosystems. This guide shows how to set up the Reason repository, build it with esy, and run its tests, and points you to where the user documentation lives. By the end you will have a working local build of the compiler and formatting tooling.

Reasonreasonml/reason · ★ 10.3k · MIT

Quick start

  1. 1Install esy. Run npm install -g esy@next to install esy globally. npm must already be available.
  2. 2Clone the repository. Run git clone https://github.com/reasonml/reason.git to download the source.
  3. 3Enter the directory. Run cd reason to move into the cloned repository.
  4. 4Build the project. Run esy in the repository directory to build Reason.
  5. 5Run the tests. Run esy test to execute the test suite and confirm the build works.
  6. 6Read the docs. Open the Getting Started page on reasonml.github.io for user-level guidance on writing Reason code.

What Reason is and who it is for

The README describes Reason as simple, fast and type safe code that leverages the JavaScript and OCaml ecosystems. It is built on OCaml, so it sits on top of that toolchain rather than replacing it.

This repository contains the compiler and formatting tooling. The user documentation is hosted on the project's website, not in this repo.

  • Good fit: developers who know JavaScript and want static types with a familiar-looking syntax.
  • Good fit: OCaml developers who prefer a JavaScript-like surface syntax.
  • Good fit: teams looking into compiling typed code to JavaScript via the OCaml ecosystem.
  • Good fit: contributors who want to work on the Reason compiler itself.
  • Poor fit: beginners looking for a first programming language, since it depends on OCaml and its tooling.

Prerequisites: what you need before installing

The README's install path requires npm, which is used to install esy. The README does not list other system requirements, so check the project docs for anything further.

  • npm installed on your machine (used to install esy).

Install esy and clone the Reason repository

The contributor setup starts by installing esy globally with npm, then cloning the repository from GitHub and moving into its directory.

npm install -g esy@next git clone https://github.com/reasonml/reason.git cd reason

Build Reason and run the tests

Once you are inside the reason directory, run esy to build the project. The README also lists esy test to run the test suite.

esy esy test # Run the tests

Find the user documentation and community

Reason's user docs, including the Getting Started page, live on the project website rather than in this repository. The repo's docs/ directory is aimed at contributors to Reason itself.

The README also links to a community page and a chat server.

  • Getting Started: https://reasonml.github.io/docs/en/installation
  • Community: https://reasonml.github.io/docs/en/community.html
  • Contributor docs: the docs/ directory in the repo

What people use it for

  • Learning Reason's JavaScript-like syntax as a typed alternative for a JavaScript developer.
  • Compiling typed code to JavaScript through the OCaml ecosystem.
  • Contributing fixes or features to the Reason compiler and formatting tooling.
  • Exploring OCaml with a surface syntax closer to JavaScript.

Frequently asked questions

Is Reason free to use?

Yes. Reason is released under the MIT licence, as stated in the repository metadata. The full licence text is in LICENSE.txt in the repo.

What do I need to install Reason?

The README's install path needs npm, which is used to install esy. You then clone the repository and run esy to build it. Check the project docs for any other requirements.

How do I install Reason?

Run npm install -g esy@next, clone https://github.com/reasonml/reason.git, cd into reason, and run esy. This is the contributor setup described in the README.

How do I run Reason's tests?

After building, run esy test from the repository directory. The README lists this command as the way to run the tests.

Where can I find Reason's documentation?

User documentation lives on the website at reasonml.github.io, including a Getting Started page. The docs/ directory in the repo is for contributors.

How does Reason compare to ReScript or TypeScript?

The README does not compare Reason to other tools, so this page cannot make that claim. ReScript, TypeScript and OCaml are listed as comparable projects, and you can evaluate them against your own needs.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Reason suits JavaScript developers who want static types in a familiar-looking syntax, and OCaml developers who prefer that surface style. It is a poor first language and a risky pick if you need a mature, widely adopted ecosystem or cannot depend on the OCaml toolchain. Contributors who want to work on the compiler itself will find the clone-and-build path the most direct way in.

Install options & downloads