diff --git a/docs/compiling-to-js-with-jsoo.md b/docs/compiling-to-js-with-jsoo.md
new file mode 100644
index 0000000000..7a7f976af3
--- /dev/null
+++ b/docs/compiling-to-js-with-jsoo.md
@@ -0,0 +1,18 @@
+---
+title: Js_of_ocaml
+---
+
+[Js_of_ocaml](https://ocsigen.org/js_of_ocaml/3.7.0/manual/overview)
+
+## Template
+
+To get started check out this [`hello-jsoo-esy`](https://github.com/jchavarri/hello-jsoo-esy) template:
+
+```
+git clone https://github.com/jchavarri/hello-jsoo-esy.git
+cd hello-jsoo-esy
+esy
+
+npm install
+npm run webpack
+```
diff --git a/docs/compiling-to-js-with-melange.md b/docs/compiling-to-js-with-melange.md
new file mode 100644
index 0000000000..cb62d811fa
--- /dev/null
+++ b/docs/compiling-to-js-with-melange.md
@@ -0,0 +1,103 @@
+---
+title: Melange
+---
+
+One of the best usages of Reason is to compile it to JavaScript an run it in the browser or any JavaScript platform such as [Node.js](https://nodejs.org), [Deno](https://deno.com), [Cloudflare Workers](https://workers.cloudflare.com).
+
+Reason compiles to JavaScript thanks to our partner project, [Melange](https://melange.re).
+
+## What's Melange?
+
+[Melange](https://melange.re) is a backend for the OCaml compiler that emits readable, modular and highly performant JavaScript code.
+
+> Melange strives to provide the best integration with both the OCaml and JavaScript ecosystems
+
+If you have experience with JavaScript and the ecosystem we recommend Melange, over other alternatives such as [Js_of_ocaml](compiling-to-js-with-jsoo.md).
+
+## Getting started
+
+The install guide on the Melange website shares a lot of common steps with [our installation](installation.md), check it out: [melange.re/v2.0.0/getting-started](https://melange.re/v2.0.0/getting-started).
+
+Since [Melange v1](https://buttondown.email/anmonteiro/archive/melange-hits-v10/), Melange integrates with dune. This means that you can use dune to compile your Reason code to JavaScript and also to bytecode or native.
+
+## Template
+
+To get started with Reason and Melange, there's an official template:
+
+```bash
+git clone https://github.com/melange-re/melange-opam-template
+cd melange-opam-template
+
+# Create opam switch and install dependencies
+make init
+
+# In separate terminals:
+
+make watch # Watch for reason file changes and recompile
+make serve # Run the development server
+```
+
+## Manual
+
+If you prefer to do all the steps manually, here is a step by step. Assuming you have an opam switch with OCaml 5.1.0. If not, check the [installation](installation.md#setup-a-new-environment-manually) guide.
+
+#### Install melange
+
+```bash
+opam install melange
+```
+
+#### Create dune-project
+
+If you don't have a `dune-project` file, create one with the following content:
+
+```lisp
+; dune-project
+(dune lang 3.8)
+(use melange 0.1) ; Here we enable melange to work with dune
+```
+
+#### Emit JavaScript
+
+In your `dune` file, add a `melange.emit` stanza to emit JavaScript.
+
+The `melange.emit` stanza tells dune to generate JavaScript files from a set of libraries and modules. In-depth documentation about this stanza can be found in the [build-system on the Melange documentation](https://melange.re/v2.0.0/build-system/#entry-points-with-melangeemit).
+
+```lisp
+; dune
+(melange.emit
+ (target app))
+```
+
+#### Libraries
+
+dune allows to define libraries by creating a dune file inside a folder and adding a library stanza: https://dune.readthedocs.io/en/stable/concepts/package-spec.html#libraries
+
+To compile a library with melange, add the `(modes melange)` stanza to the library dune file.
+
+```diff
+(library
+ (name ui_library)
++ (modes melange)
+)
+```
+
+Once you have a melange library, you can add it to the `melange.emit` stanza:
+```lisp
+; dune
+(melange.emit
+ (target app)
+ (libraries ui_library))
+```
+
+#### Compile
+
+Each time you compile the project, dune will emit JavaScript files under `_build/default/app/` (`app` comes from the `(target app)` defined under `melange.emit`).
+
+To compile the project, run:
+
+```bash
+dune build # Compile the entire project
+# or compile the melange alias (only melange.emit stanzas)
+dune build @melange
+```
diff --git a/docs/converting-from-js.md b/docs/converting-from-js.md
index 4161af3d26..b8a566123f 100644
--- a/docs/converting-from-js.md
+++ b/docs/converting-from-js.md
@@ -2,4 +2,6 @@
title: Converting from JS
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/converting-from-js. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+This section has been moved to ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/converting-from-js. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+
+Some parts aren't relevant anymore, but the general idea is still the same. The process of introducing a new language to your project applies for Reason also.
diff --git a/docs/editor-plugins.md b/docs/editor-plugins.md
index eb17a31e50..d1da924971 100644
--- a/docs/editor-plugins.md
+++ b/docs/editor-plugins.md
@@ -15,7 +15,7 @@ And other features.
## Editor Plugins & Language Server
-Since Reason is just an alternative syntax for OCaml, we integrate seamlessly into the official OCaml editor toolchain as well.
+The OCaml Platform provides support for Reason and integrates with editors such as VSCode, Vim, or Emacs.
- For VSCode, we recommend using the [vscode-ocaml-platform](https://github.com/ocamllabs/vscode-ocaml-platform) plugin, which offers OCaml & Reason support out of the box.
- For other editors, we recommend using a language server client plugin of your choice, and pairing it with the [`ocaml-lsp`](https://github.com/ocaml/ocaml-lsp). Check out the respective README's to get started.
@@ -24,3 +24,5 @@ Since Reason is just an alternative syntax for OCaml, we integrate seamlessly in
- [Vim/Neovim](https://github.com/reasonml-editor/vim-reason-plus): Make sure to use [ocaml-language-server](https://www.npmjs.com/package/ocaml-language-server) for native development as suggested. (Mac, Linux): `npm install -g ocaml-language-server`
- [vim-reasonml](https://github.com/jordwalke/vim-reasonml): For use with [esy](https://esy.sh/), Reason, and Merlin (not LSP based). (Mac, Linux, Windows).
+- [Sublime Text](https://github.com/reasonml-editor/sublime-reason)
+- [IDEA](https://github.com/reasonml-editor/reasonml-idea-plugin)
diff --git a/docs/events.md b/docs/events.md
index c1988944a3..f9458e3046 100644
--- a/docs/events.md
+++ b/docs/events.md
@@ -8,13 +8,14 @@ There are a Reason meetups all around the world, among others:
- [Chicago](https://www.meetup.com/Chicago-ReasonML/)
- [Copenhagen](https://www.meetup.com/ReasonML-CPH) ([Twitter](https://twitter.com/ReasonMLCPH))
- [Göteborg](https://www.meetup.com/got-lambda/)
-- [Lisbon](https://www.meetup.com/ReasonML-Lisbon)
- [Montreal](https://www.meetup.com/ReasonMTL/)
+- [New York](https://twitter.com/nycreasonml)
- [Paris](https://www.meetup.com/ReasonML-Paris/)
-- [Phoenix](https://www.meetup.com/Phoenix-Reason)
+- [Portland](https://twitter.com/ReasonPDX)
- [Prague](https://www.meetup.com/Reason-Prague/) ([Twitter](https://twitter.com/ReasonPrague))
- [San Francisco](https://www.meetup.com/sv-ocaml/)
- [Seattle](https://www.meetup.com/Seattle-ReasonML-OCaml-Meetup/)
- [Stockholm](https://www.meetup.com/ReasonSTHLM/)
+- [Vienna](https://www.meetup.com/Reason-Vienna/) ([Twitter](https://twitter.com/reasonvienna))
If you don't find your local area's Reason meetup, search on https://meetup.com or start one!
diff --git a/docs/faq.md b/docs/faq.md
index 174002d32f..b8377d8f49 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -4,14 +4,39 @@ title: Frequently Asked Questions
### I'm not sure what to do with Reason
-You can do all the things you'd usually do with OCaml! OCaml is an incredible useful language for systems programming, while still being able to compile to pretty type safe JS with the aid of the `js_of_ocaml` compiler.
+You can do all the things you'd usually do with JavaScript or OCaml! OCaml is an incredible useful language for general programming, while still being able to compile to pretty type safe JS with the aid of the [`Melange`](https://melange.re/v2.0.0/) compiler.
-Natively compiled CLI's are also known to be really fast (like... C-like fast), and since the language is garbage collected, you will find yourself in a very nice spot of not having to worry about borrow-checking like in Rust and you don't have to deal with verbose non-ML languages like Go.
+Natively compiled CLI's are also known to be really fast (like... C-like fast), and since the language is garbage collected, you will find yourself in a very nice spot of not having to worry about borrow-checking like in Rust and you don't have to deal with verbose non-ML languages like Go.
Reason also gives access to the declarative UI framework [revery-ui](https://github.com/revery-ui/revery) to build native applications with a ReactJS like paradigm (+ JSX).
### What is BuckleScript and ReScript, and why is it mentioned in so many Reason related resources?
-Reason was originally bundled with BuckleScript (JS compiler) to provide a single toolchain for JS / ReactJS development.
+Reason was originally integrated with BuckleScript to provide a single toolchain for JavaScript and React.js development.
In July 2020, BuckleScript released its own syntax and rebranded to ReScript to be its own language. More infos can be found in their [official rebranding announcement](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+
+### Where do all these `print_endline`, `string_of_int` functions come from?
+They're from the standard library, pre-`open`ed during the compilation of your file. This is why you see them in scope.
+
+You can read more about the Pervasives library in the api documentation:
+
+https://reasonml.github.io/api/Pervasives.html
+
+### Why is there a + for adding ints and +. for adding floats, etc.?
+See [here](integer-and-float.md#design-decisions).
+
+### What's the `.merlin` file at the root of my project?
+That's the metadata file for [editor support](editor-plugins.md). This is usually generated for you; You don't need to check that into your version control and don't have to manually modify it.
+
+### I don't see any `import` or `require` in my file; how does module resolution work?
+Reason/OCaml doesn't require you to write any import; modules being referred to in the file are automatically searched in the project. Specifically, a module `Hello` asks the compiler to look for the file `hello.re` or `hello.ml` (and their corresponding [interface file](module.md#signatures), `hello.rei` or `hello.mli`, if available).
+
+### Is `Some | None`, `contents`, `Array`, `List` and all of these special? Where do they come from?
+They're ordinary variants/records/module definitions that come with the [standard library](/api/index.html), `open`ed by default during compilation out of convenience.
+
+### What's this `MyModule.t` I keep seeing?
+Assuming `MyModule` is a module's name, `t` is a community convention that indicates "the type that represents that module, whatever that means". For example, for the [`Js.String`](http://bucklescript.github.io/bucklescript/api/Js.String.html) module, [`String.t`](http://bucklescript.github.io/bucklescript/api/Js.String.html#TYPEt) is the type carried around and representing "a string".
+
+### What does an argument with a prepended underscore (e.g. `_` or `_foo`) mean?
+Say you have `List.map(item => 1, myList);`. The argument `item` isn't used and will generate a compiler warning. Using `_ => 1` instead indicates that you're intentionally receiving and ignoring the argument, therefore bypassing the warning. Alternatively, `_item => 1` has the same effect, but indicates more descriptively what you're ignoring.
diff --git a/docs/getting-started.md b/docs/getting-started.md
new file mode 100644
index 0000000000..f0c632b3de
--- /dev/null
+++ b/docs/getting-started.md
@@ -0,0 +1,42 @@
+---
+title: Getting started
+---
+
+This section of the docs is all about quickly setting up a Reason development enviromanet up and running.
+
+## Get an overview of Reason
+
+```reason
+type schoolPerson =
+ | Teacher
+ | Director
+ | Student(string);
+
+let greeting = person =>
+ switch (person) {
+ | Teacher => "Hey Professor!"
+ | Director => "Hello Director."
+ | Student("Richard") => "Still here Ricky?"
+ | Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "."
+ };
+
+module Intro = {
+ [@react.component]
+ let make = (~person) => {
+
{React.string(greeting(person))}
+ }
+};
+```
+> This snippet includes [@react.component] which comes from [reason-react](https://reasonml.github.io/reason-react/)
+
+For an introduction to most language features check out the [overview](overview.md)
+
+## Try Reason in your browser
+
+To start immediately an online REPL is available at [Sketch.sh](https://sketch.sh)
+or open the [playground](playground)
+
+## Install Reason
+
+Install Reason on your computer to start writing Reason applications.
+Check the [installation](installation.md) for a more detailed guide.
diff --git a/docs/installation-esy.md b/docs/installation-esy.md
new file mode 100644
index 0000000000..61dcba837c
--- /dev/null
+++ b/docs/installation-esy.md
@@ -0,0 +1,62 @@
+---
+title: Installation via esy
+---
+
+This page is a detailed explanation on how to install Reason with [esy](https://esy.sh/) Easy package management for native Reason, OCaml and more, both manually and using a template.
+
+Reason can be installed with a package manager like [opam](https://opam.ocaml.org/) also, check the [installation page](installation.md) for more details.
+
+### Requirements
+
+System Requirements:
+
+- Node.js 16.14 or later.
+- macOS, Windows (including WSL), and Linux are supported.
+
+Esy is distributed via npm, install it using the following command:
+
+```
+npm install -g esy
+```
+> It's recommended to install esy globally
+
+### Automatic
+Using the [`hello-reason`](https://github.com/esy-ocaml/hello-reason) template
+
+### Manual installation
+
+To add packages that happen to be hosted on npm, run `esy add npm-package-name`.
+
+To add packages from opam's registry, prefix the package name with `@opam`. `esy` treats the npm scope `@opam` specially. In this case, `esy` will install any package name with the `@opam` scope directly from [opam](https://opam.ocaml.org/packages/).
+
+```bash
+esy add @opam/bos
+```
+
+
+
+We install reason from opam using the following command:
+
+```
+esy add @opam/reason
+```
+
+Link to getting started with esy https://esy.sh/docs/en/getting-started.html
+See the [configuration](https://esy.sh/docs/en/configuration.html) section from the complete `esy` docs.
+
+To create your first Reason native CLI program, run the following commands:
+
+```
+git clone https://github.com/esy-ocaml/hello-reason.git
+cd hello-reason
+
+# Install all dependencies (might take a while in the first run)
+esy
+
+# Compile and run Hello.exe
+esy x Hello
+```
+
+## What's Next?
+
+After you have successfully compiled your first example, it's time to [set up your editor](editor-plugins.md) to get access to all the nice features such as auto-completion. Later on you can check out the [language basics](overview.md) to get a basic understanding of all the Reason language constructs.
diff --git a/docs/installation.md b/docs/installation.md
index 129a134d01..a491cc9430 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -2,73 +2,102 @@
title: Installation
---
-> **Important:** If you are looking for ReScript (formerly BuckleScript) installation instructions, please refer to the [ReScript website](https://rescript-lang.org/docs/manual/latest/installation).
+This page is a detailed explanation on how to install Reason with [opam](https://opam.ocaml.org/), both manually and using a template. There are other options available, such as [esy](https://esy.sh), but we recommend using opam for the best experience. Check the [esy installation page](installation-esy.md) if you want to use esy instead.
-Reason comes with its own "npm like" package manager called [esy](https://esy.sh):
+### System requirements
+- macOS and Linux are supported natively
+- Windows is supported via WSL (https://ocaml.org/docs/ocaml-on-windows)
-```
-npm install -g esy
-```
+## Install the package manager
+
+[opam](https://opam.ocaml.org) (short for OCaml Package Manager) is a tool for managing packages and environments. If you haven't installed opam yet, please follow the instructions provided on the [official website](https://opam.ocaml.org/doc/Install.html). Be aware that the initial setup might be notably slow due to compiler retrieval and build processes.
+
+### Using a template
+
+This template serves as a solid foundation, integrating essential configurations and structure to expedite your development process. Simply follow the link to access the template and initiate your ReasonML project effortlessly.
-To create your first Reason native CLI program, run the following commands:
+We recommend this method for beginners.
+**Repository** [melange-re/melange-opam-template](https://github.com/melange-re/melange-opam-template)
+
+The template comes from the [Melange](https://melange.re) team, since it's a common duo to use Reason with Melange.
+Melange is a compiler that emits JavaScript, from Reason code. You can find all the information about Melange in their docs: https://melange.re
+
+### Setup a new environment manually
+
+opam needs to be initialised (Initialize `~/.opam`). This step is only required once.
+
+```bash
+opam init -y
```
-git clone https://github.com/esy-ocaml/hello-reason.git
-cd hello-reason
-# Install all dependencies (might take a while in the first run)
-esy
+During opam init, you will be asked if you want to add a hook to your shell to put the tools available in the current opam switch on your PATH.
-# Compile and run Hello.exe
-esy x Hello
+```bash
+eval $(opam env)
```
-Reason native development is essentially OCaml development. From here on, you want to read up following websites to get to understand the ecosystem:
+### Create switch
-- **esy**: The `esy` package manager is designed to manage your npm and opam dependencies and efficiently caches & sandboxes your project compiler and dependencies. Check out the [esy website](https://esy.sh) to find out how to install dependencies, setting up package resolutions, and executing compiled programs.
-- **opam**: The [opam package index](https://opam.ocaml.org/packages/) lists all available packages available in the OCaml ecosystem
-- **dune**: [`dune`](https://github.com/ocaml/dune) is the official build system in the OCaml ecosystem. Check out the [manual](https://dune.readthedocs.io/en/latest/) for more details on how to set up your project.
+opam is now installed and configured. Before installing Reason, we need to create a switch which is set of packages that are installed in a given compiler version. This is similar to how [nvm](https://github.com/nvm-sh/nvm) manages different versions of packages on a Node version.
-All your packages are managed in your `package.json` file. Usually you will find a `dune` file in each source code directory (such as `bin/` and `lib/`) for all the build system settings as well.
+```bash
+opam switch create . 5.1.0 --deps-only
+```
+For a comprehensive guide on how to create an opam switch, refer to the following link: [ocaml.org/docs/installing-ocaml#create-an-opam-switch](https://ocaml.org/docs/up-and-running#3-create-an-opam-switch).
-### Some `esy` Tips
+### Install reason
-**Adding dependencies:**
+```
+opam install reason
+```
+
+Once the instalation of the [`reason`](https://opam.ocaml.org/packages/reason) package is done you will have available the following tools `refmt` and `rtop` and there's no configuration change to enable the build system (dune) to build your code.
-To add Reason / OCaml packages that happen to be hosted on npm, run `esy add npm-package-name`.
+Make sure you have installed the latest version of `refmt` and `rtop` by running the following command:
```
-esy add refmterr
+refmt --version
```
-**Opam integration:**
+## Install the build system
-`esy` treats the npm scope `@opam` specially. `esy` will install any package name with the `@opam` scope directly from [opam](https://opam.ocaml.org/packages/). This is the only scope with special meaning. All other package names are assumed to be hosted on npm.
+We introduced the build-system called `dune` that Reason projects can use to specify libraries, executables and applications. It’s optimized for monorepos and makes project maintenance easier. Check their docs in case you want to learn more about it: [dune.build](https://dune.build/).
```
-esy add @opam/bos
+opam install dune
```
-**Advanced esy configuration:**
+## Hello world
-See the [configuration](https://esy.sh/docs/en/configuration.html) section from the complete `esy` docs.
+To wrap up the installation process, let's create a simple hello world project. With the basic setup done:
-## Compiling to JavaScript
+Create a file `hello.re` with the following content:
+```
+print_endline("Hello world!");
+```
-Reason + OCaml both leverage the [js_of_ocaml (JSOO)](https://ocsigen.org/js_of_ocaml/3.7.0/manual/overview) compiler to compile from bytecode to JavaScript.
+Create a file `dune` with the following content:
+```
+(executable
+ (name hello)
+ (public_name hello))
+```
+> Note: dune uniformly uses the .exe extension to build native executables, even on Unix where programs don’t usually have a .exe extension.
-To get started with Reason + esy + JSOO, check out this [`hello-jsoo-esy`](https://github.com/jchavarri/hello-jsoo-esy) template:
+The `executable` stanza is used to define executables and the `name` field is used to specify the name of the executable (Can run with `dune exec src/hello.exe`). The `public_name` field is used to specify the name of the executable when it is installed and allows you to run the executable with `hello` directly: `dune exec hello`.
+Run the project (this will compile the project and run the executable):
```
-git clone https://github.com/jchavarri/hello-jsoo-esy.git
-cd hello-jsoo-esy
-esy
+dune exec hello
+```
+If you want to build only:
-npm install
-npm run webpack
+```
+dune build
```
## What's Next?
-After you have successfully compiled your first example, it's time to [set up your editor](editor-plugins.md) to get access to all the nice features such as auto-completion. Later on you can check out the [language basics](overview.md) to get a basic understanding of all the Reason language constructs.
+After you have successfully intalled Reason, it's time to [set up your editor](editor-plugins.md) to get access to all the nice features such as auto-completion. Later on you can check out the [language basics](overview.md) to get a basic understanding of all the Reason language constructs.
diff --git a/docs/interop.md b/docs/interop.md
index 97df8272f4..e64528be50 100644
--- a/docs/interop.md
+++ b/docs/interop.md
@@ -2,4 +2,6 @@
title: Interop
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/introduction. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+Interoperability with JavaScript is a first-class feature of Melange. This section will cover the different ways you can interact with JavaScript code from Reason using Melange.
+
+This section is documented under Melange's documentation: [Communicate with JavaScript](https://melange.re/v2.0.0/communicate-with-javascript/).
diff --git a/docs/jsx.md b/docs/jsx.md
index 03dcdb5c0d..ec3500b238 100644
--- a/docs/jsx.md
+++ b/docs/jsx.md
@@ -2,11 +2,26 @@
title: JSX
---
-> **Note:** If you are looking for ReasonReact specific JSX infos, please refer to the [ReScript JSX docs](https://rescript-lang.org/docs/manual/v8.0.0/jsx) instead.
+JSX is a syntax extension for HTML-like syntax inside a JavaScript file. It's a convenient way to write React components.
-Would you like some HTML syntax in your Reason? If not, quickly skip over this section and pretend you didn't see anything!
+Reason has built in support for JSX at the language-level, so you can use it without any extra tooling.
-Reason supports the JSX syntax, with some slight differences compared to the one in [ReactJS](https://facebook.github.io/react/docs/introducing-jsx.html). Reason JSX isn't tied to ReactJS; they translate to normal function calls:
+The design is slight different compared to the one in [React](https://facebook.github.io/react/docs/introducing-jsx.html), since Reason JSX isn't tied to React and it translate to normal function calls.
+
+### Features of Reason JSX
+- Components are modules with a `make` function
+- Props are labeled arguments
+- Adds dynamic expressions that allow you to reference variables and functions within your JSX by using the `{ }` (block-scoped) syntax
+
+### Departures from JavaScript JSX
+
+- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you format your file, some of them go away and some turn into parentheses.
+- There is no support for JSX prop spread: ``. Though somewhat related, we do have children spread, described above: ` ...baz `.
+- Punning [See below](#punning)
+
+# Syntax
+
+Here's a quick overview of the syntax, and example of how it transforms to normal function calls.
## Capitalized Tag
@@ -32,10 +47,12 @@ becomes
([@JSX] div(~foo=bar, ~children=[child1, child2], ()));
```
+`[@JSX]` is just an attribute for hooking up ppxes. As an example, [reason-react-ppx](https://reasonml.github.io/reason-react/) turns that agnostic `div` call into something React-specific.
+
## Fragment
```reason
-<> child1 child2 >;
+<> child1 child2 >
```
becomes
@@ -88,18 +105,13 @@ Here's a JSX tag that shows most of the features.
booleanAttribute={true}
stringAttribute="string"
intAttribute=1
+ optionalProp={Some("hello")}
forcedOptional=?{Some("hello")}
- onClick={send(handleClick)}>
+ onClick={event => handleClick(event)}>
{"hello"}
```
-## Departures From JS JSX
-
-- Attributes and children don't mandate `{}`, but we show them anyway for ease of learning. Once you `refmt` your file, some of them go away and some turn into parentheses.
-- There is no support for JSX prop spread: ``. Though somewhat related, we do have children spread, described above: ` ...baz `.
-- Punning!
-
### Punning
"Punning" refers to the syntax shorthand for when a label and a value are the same. For example, in JavaScript, instead of doing `return {name: name}`, you can do `return {name}`.
@@ -112,12 +124,16 @@ Reason JSX supports punning. `` is just a shorthand for `` desugars to ``, in order to conform to DOM's idioms and for backward compatibility.
+**Note** that this is a big difference from ReactJS JSX, which does **not** have punning. ReactJS' `` means ``, in order to conform to DOM's idioms and for backward compatibility.
## Frameworks using JSX
-- [**ReveryUI**](https://www.outrunlabs.com/revery/api/revery/#Overview): A ReactJS-like UI framework for building cross-platform GUI applications
+Aside from the tight integration with [**`reason-react`**](https://reasonml.github.io/reason-react/), there are a few libraries that are build on top of JSX in Reason. The following list is not exhaustive, and the quality of the libraries may vary.
+- [**ReveryUI**](https://www.outrunlabs.com/revery/api/revery/#Overview): A ReactJS-like UI framework for building cross-platform GUI applications
+- [**jsoo-react**](https://github.com/ml-in-barcelona/jsoo-react): js_of_ocaml bindings for ReactJS
+- [**brisk**](https://github.com/briskml/brisk): Cross-platform set of tools for building native UIs with Reason/OCaml
+- [**ppx-tea-jsx**](https://github.com/osener/ppx-tea-jsx): Reason JSX syntax for BuckleScript-TEA
## Tip & Tricks
diff --git a/docs/libraries.md b/docs/libraries.md
index fa63fce3fe..01917e60cc 100644
--- a/docs/libraries.md
+++ b/docs/libraries.md
@@ -2,4 +2,6 @@
title: Libraries
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/libraries. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+Reason libraries are just like OCaml libraries: hosted on opam. Here's a list of packages published by on the opam repository written in Reason: https://ocaml.org/p/reason/latest#used-by
+
+Historically you can find some libraries on npm as well, since previously Reason and BuckleScript (now ReScript), but we're moving away from that. The npm packages are mostly outdated and might reference parts of Reason that aren't correct anymore. The main motiv is that we want to focus on the opam ecosystem, which is the standard for OCaml libraries, [ppxs](https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem/) and tools.
diff --git a/docs/pattern-matching.md b/docs/pattern-matching.md
index 4d997d4423..2d5c7c4e71 100644
--- a/docs/pattern-matching.md
+++ b/docs/pattern-matching.md
@@ -132,15 +132,15 @@ type point = {
type t =
| A((string, int))
- | B(r)
+ | B(point)
| C(array(int))
- | D(list(r));
+ | D(list(point));
-let x = D([{x: 2, y: 1.2}]);
+let x = D([{x: 2, y: 1}]);
switch (x) {
| A(("hi", num)) => num
-| B({x, y: 1.2}) => x
+| B({x, y: 1}) => x
| C([|x|]) => x
| C([|2, 3, x|]) => x
| D([]) => 2
@@ -156,8 +156,8 @@ switch (x) {
```reason
switch (x) {
| A(("hi", num)) as v => f(v)
-| B({x: _, y: 1.2} as r) => g(r)
-| D([{x: _, y: 1.2} as r, ..._]) => g(r)
+| B({x: _, y: 1} as r) => g(r)
+| D([{x: _, y: 1} as r, ..._]) => g(r)
| _ => 42
};
```
diff --git a/docs/pipe-first.md b/docs/pipe-first.md
index 4de13e360f..c8ae57a74f 100644
--- a/docs/pipe-first.md
+++ b/docs/pipe-first.md
@@ -2,4 +2,41 @@
title: Pipe First
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/pipe. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+Pipe first is the operator to apply a function to a value where data is passed as the first argument. `->` is a convenient operator that allows you to "flip" your code inside-out. `a(b)` becomes `b->a`.
+
+```reason
+let result = value->function;
+```
+
+Imagine you have the following:
+
+```reason
+validateAge(getAge(parseData(person)))
+```
+
+This is slightly hard to read, since you need to read the code from the innermost part, to the outer parts. Use Pipe First to streamline it
+
+```reason
+person
+ ->parseData
+ ->getAge
+ ->validateAge
+```
+
+Basically, `parseData(person)` is transformed into `person->parseData`, and `getAge(person->parseData)` is transformed into `person->parseData->getAge`, etc.
+
+**This works when the function takes more than one argument too**.
+
+```reason
+a(one, two, three)
+```
+
+is the same as
+
+```reason
+one->a(two, three)
+```
+
+This works with labeled arguments too.
+
+This section is documented under Melange's documentation as well: [Pipe first](https://melange.re/v2.0.0/communicate-with-javascript/#pipe-first).
diff --git a/docs/promise.md b/docs/promise.md
index fffbbfbd47..4855baf089 100644
--- a/docs/promise.md
+++ b/docs/promise.md
@@ -2,4 +2,4 @@
title: Promise
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/promise. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+Promise support comes from Melange's [Js.Promise](https://melange.re/v2.0.0/api/re/melange/Js/Promise/index.html) module.
diff --git a/docs/refmt.md b/docs/refmt.md
new file mode 100644
index 0000000000..210cad482f
--- /dev/null
+++ b/docs/refmt.md
@@ -0,0 +1,89 @@
+---
+title: Format (refmt)
+---
+
+`refmt` stands by Reason Formatter and it formats Reason programs, is a parser and pretty-printer for Reason.
+
+`refmt` can easily convert Reason code to OCaml code and vice versa, since Reason and OCaml are compatible on the AST-level.
+
+Comes inside the [`reason`](https://opam.ocaml.org/packages/reason) package from the [opam repository](https://opam.ocaml.org/packages/reason/).
+
+## Installation
+
+```bash
+opam install reason
+```
+
+## Usage
+
+It comes integrated automatically in `dune`, so you don't need to do anything to use it, but you can use it directly from the command line via `refmt` directly or via dune.
+
+```bash
+dune build @fmt
+# or
+refmt
+```
+
+## Help
+
+```bash
+REFMT(1) Refmt Manual REFMT(1)
+
+NAME
+ refmt - Reason´s Parser & Pretty-printer
+
+SYNOPSIS
+ refmt [OPTION]... [FILENAMES]...
+
+DESCRIPTION
+ refmt lets you format Reason files, parse them, and convert them
+ between OCaml syntax and Reason syntax.
+
+ARGUMENTS
+ FILENAMES
+ input files; if empty, assume stdin
+
+OPTIONS
+ -e, --assume-explicit-arity
+ if a constructor´s argument is a tuple, always interpret it as
+ multiple arguments
+
+ -h VAL, --heuristics-file=VAL
+ load path as a heuristics file to specify which constructors carry
+ a tuple rather than multiple arguments. Mostly used in removing
+ [@implicit_arity] introduced from OCaml conversion. example.txt:
+ Constructor1 Constructor2
+
+ --help[=FMT] (default=pager)
+ Show this help in format FMT (pager, plain or groff).
+
+ -i VAL, --interface=VAL (absent=false)
+ parse AST as an interface
+
+ --in-place
+ reformat a file in-place
+
+ -p FORM, --print=FORM (absent=re)
+ print AST in FORM, which is one of: (ml | re (default) | binary
+ (for compiler input) | binary_reason (for interchange between
+ Reason versions) | ast (print human readable AST directly) | none)
+
+ --parse=FORM
+ parse AST in FORM, which is one of: (ml | re | binary (for compiler
+ input) | binary_reason (for interchange between Reason versions))
+
+ -r, --recoverable
+ enable recoverable parser
+
+ --version
+ Show version information.
+
+ -w COLS, --print-width=COLS (absent=80 or REFMT_PRINT_WIDTH env)
+ wrapping width for printing the AST
+
+ENVIRONMENT VARIABLES
+ REFMT_PRINT_WIDTH
+ wrapping width for printing the AST
+
+Refmt Reason 3.10.0 @ 747c8c3 REFMT(1)
+```
diff --git a/docs/rtop.md b/docs/rtop.md
new file mode 100644
index 0000000000..d8885c268f
--- /dev/null
+++ b/docs/rtop.md
@@ -0,0 +1,44 @@
+---
+title: REPL (rtop)
+---
+
+`rtop` is a REPL (Read, Evaluate, Print, and Loop) to interact with Reason.
+
+Comes from the [`rtop`](https://opam.ocaml.org/packages/rtop) package in the [opam repository](https://opam.ocaml.org/packages/rtop/).
+
+Inspired by [utop](https://github.com/ocaml-community/utop)
+
+## Installation
+
+```bash
+opam install rtop
+```
+
+## Usage
+
+```bash
+rtop
+```
+```bash
+─────────────┬─────────────────────────────────────────────────────────────┬──────────────
+ │ Welcome to utop version 2.13.1 (using OCaml version 5.0.0)! │
+ └─────────────────────────────────────────────────────────────┘
+
+ ___ _______ ________ _ __
+ / _ \/ __/ _ | / __/ __ \/ |/ /
+ / , _/ _// __ |_\ \/ /_/ / /
+ /_/|_/___/_/ |_/___/\____/_/|_/
+
+ Execute statements/let bindings. Hit after the semicolon. Ctrl-d to quit.
+
+ > let myVar = "Hello Reason!";
+ > let myList: list(string) = ["first", "second"];
+ > #use "./src/myFile.re"; /* loads the file into here */
+
+Type #utop_help for help about using utop.
+
+Reason #
+┌──────────────┬──────────────┬───────────────┬─────┬────┬───┬──────────┬─────┬──────────┐
+│Afl_instrument│Alias_analysis│Allocated_const│Annot│Arch│Arg│Arg_helper│Array│ArrayLabel│
+└──────────────┴──────────────┴───────────────┴─────┴────┴───┴──────────┴─────┴──────────┘
+```
diff --git a/docs/syntax-cheatsheet.md b/docs/syntax-cheatsheet.md
index f6769c723a..8031ad636a 100644
--- a/docs/syntax-cheatsheet.md
+++ b/docs/syntax-cheatsheet.md
@@ -2,4 +2,210 @@
title: Syntax Cheatsheet
---
-This section has been moved to the new ReScript project: https://rescript-lang.org/docs/manual/v8.0.0/overview. More info on the transition [here](https://rescript-lang.org/blog/bucklescript-is-rebranding).
+Here is the cheat sheet with some equivalents between JavaScript and Reason syntaxes:
+
+### Variable
+
+| JavaScript | Reason |
+|-------------------------|--------------------------------|
+| `const x = 5;` | `let x = 5;` |
+| `var x = y;` | No equivalent |
+| `let x = 5; x = x + 1;` | `let x = ref(5); x := x^ + 1;` |
+
+### String & Character
+
+| JavaScript | Reason |
+|------------------------|-----------------------|
+| `"Hello world!"` | Same |
+| `'Hello world!'` | Strings must use `"` |
+| Characters are strings | `'a'` |
+| `"hello " + "world"` | `"hello " ++ "world"` |
+
+### Boolean
+
+| JavaScript | Reason |
+|-------------------------------------------------------|-----------------------------------|
+| `true`, `false` | Same |
+| `!true` | Same |
+| `||`, `&&`, `<=`, `>=`, `<`, `>` | Same |
+| `a === b`, `a !== b` | Same |
+| No deep equality (recursive compare) | `a == b`, `a != b` |
+| `a == b` | No equality with implicit casting |
+
+### Number
+
+| JavaScript | Reason |
+|-------------|-----------------------|
+| `3` | Same \* |
+| `3.1415` | Same |
+| `3 + 4` | Same |
+| `3.0 + 4.5` | `3.0 +. 4.5` |
+| `5 % 3` | `5 mod 3` |
+
+\* JavaScript has no distinction between integer and float.
+
+### Object/Record
+
+| JavaScript | Reason |
+|---------------------|-----------------------------------------|
+| no static types | `type point = {x: int, mutable y: int}` |
+| `{x: 30, y: 20}` | Same |
+| `point.x` | Same |
+| `point.y = 30;` | Same |
+| `{...point, x: 30}` | Same |
+
+### Array
+
+| JavaScript | Reason |
+|-----------------------|------------------------------------|
+| `[1, 2, 3]` | \[\|1, 2, 3\|\] |
+| `myArray[1] = 10` | Same |
+| `[1, "Bob", true]` \* | `(1, "Bob", true)` |
+| No immutable list | `[1, 2, 3]` |
+
+\* Tuples can be simulated in JavaScript with arrays, as JavaScript arrays can
+contain multiple types of elements.
+
+### Null
+
+| JavaScript | Reason |
+|---------------------|-----------------------|
+| `null`, `undefined` | `None` \* |
+
+\* There are no nulls, nor null bugs in OCaml. But it does have [an option type](https://reasonml.github.io/docs/en/option) for when you actually need nullability.
+
+### Function
+
+| JavaScript | Reason |
+|---------------------------------|----------------------------|
+| `arg => retVal` | `(arg) => retVal` |
+| `function named(arg) {...}` | `let named = (arg) => ...` |
+| `const f = function(arg) {...}` | `let f = (arg) => ...` |
+| `add(4, add(5, 6))` | Same |
+
+#### Blocks
+
+
@@ -153,7 +158,7 @@ class Index extends React.Component {
},
{
title: Use the power of the OCaml ecosystem,
- content: Get access to the powerful systems programming language OCaml with an easier to learn syntax. Use js_of_ocaml to compile to JavaScript!,
+ content: Get access to the powerful systems programming language OCaml with an easier to learn syntax. Use Melange to compile to JavaScript!,
},
]}
layout="threeColumn"
diff --git a/website/sidebars.json b/website/sidebars.json
index fd2b039f6e..5ce4b9a9af 100644
--- a/website/sidebars.json
+++ b/website/sidebars.json
@@ -1,11 +1,13 @@
{
"docs": {
"Intro": [
- "what-and-why"
+ "what-and-why",
+ "getting-started"
],
"Setup": [
"installation",
- "editor-plugins"
+ "editor-plugins",
+ "refmt"
],
"Language Basics": [
"overview",
@@ -31,6 +33,7 @@
"object"
],
"JavaScript": [
+ "compiling-to-js-with-melange",
"interop",
"syntax-cheatsheet",
"pipe-first",
@@ -40,7 +43,8 @@
],
"Extra": [
"faq",
- "extra-goodies"
+ "extra-goodies",
+ "rtop"
]
},
"community": {