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.
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!