type schoolPerson = Teacher | Director | Student string;

let greeting stranger =>
  switch stranger {
  | Teacher => "Hey professor!"
  | Director => "Hello director."
  | Student "Richard" => "Still here Ricky?"
  | Student anyOtherName => "Hey, " ^ anyOtherName ^ "."
  };

Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.

Types without hassle

Powerful, safe type inference means you rarely have to annotate types, but everything gets checked for you.

Easy JavaScript interop

Use packages from NPM/Yarn with minimum hassle, or even drop in a snippet of raw JavaScript while you're learning!

Flexible & Fun

Make websites, animations, games, servers, cli tools, and more! Take a look at these examples to get inspired.

JavaScript Quick Start

npm install -g bs-platform
bsb -init my-first-app -theme basic-reason

And then run it as usual:

cd my-first-app
npm run start

It runs in watch mode, so any changes to files will be picked up and compiled.

That's all! This compiles Reason to Javascript in the lib/js/ folder.

  • Read more about how we compile to JavaScript through our partner project, BuckleScript.

  • Alternatively, to start a ReasonReact app, try bsb -init my-react-app -theme react.

  • Head over to Editor Setup to get the Reason plugin for your favorite editor!