Quick StartTryGuideAPICommunityBlogGitHub
Search

Extra GoodiesSuggest an edit

Browser Extension: Reason-tools

Reason-tools lets you quickly toggle between OCaml syntax and Reason syntax when you're browsing tutorials and documentations written in either syntax.

BuckleScript

You'll be seeing BuckleScript extensively throughout the rest of this documentation, since it's the engine that powers our JS compilation. Its global binaries are installed through npm install -g bs-platform.

Other Utilities

The global installation you've done in the past section comes with a few extra useful tools, described here.

Refmt

refmt ("Reason format") is the binary that powers our editors' auto-formatting feature. It takes in your code and spits it out, nicely formatted. It also serves to convert to/from Reason/OCaml syntax. The Reason community uses it to achieve a consistent code style throughout different projects, and to avoid time-consuming manual formatting & stylistic debates. Here it is, used inside Vim:

It responsively formatted the code based on the editor width (just to show a point). In other words, it doesn't just naively break to the next line at a certain characters limit; it solves the layout constrains and arranges your code accordingly.

refmt can be used directly in the terminal. For example, to format your code outside of the editor, do refmt --in-place myFile.re. See refmt --help for all the options.

Merlin

Merlin is the underlying engine powering type hint, refactor, real-time errors, jump to definitions, etc. to our editors. Its command line name is called ocamlmerlin, though you wouldn't call it manually (editors start it themselves and query it).

To configure Merlin to understand your project, you'd write a .merlin file at the root (documentation here). For the JS workflow, this configuration is generated for you automatically by BuckleScript's bsb.

REPL

Reason comes with a REPL called rtop which, once invoked, lets you interactively evaluate code. It features intelligent, type-driven autocompletion.

Use #quit; to close your REPL session.

Note that rtop currently doesn't work easily with packages and externals. We recommend evaluating code inside our Try playground.

ocamlc, ocamlopt, ocamlrun, rebuild

ocamlc and ocamlopt are the bare ocaml compilers.