<commit_before># Core Reason

**See a list of easy tasks [here](https://github.com/facebook/reason/labels/GOOD%20FIRST%20TASK)**

## Contributor Setup

Thanks for considering contributing to Reason! Here's the setup you need:

### With opam

```sh
# On OSX, install opam via Homebrew:
brew update
brew install opam
# On Linux, see here (you will need opam >= 1.2.2): http://opam.ocaml.org/doc/Install.html

opam init
# Add this to your ~/.bashrc (or ~/.zshrc), then do `source ~/.bashrc`
#   eval $(opam config env)

opam update
opam switch 4.04.2
eval $(opam config env)
git clone https://github.com/facebook/reason.git
cd reason
opam pin add -y reason .
```

### With esy

The esy workflow is still experimental.
If you would like to help test, you can try it with the following commands.

```sh
npm install -g esy
git clone https://github.com/facebook/reason.git
cd reason
esy install
esy build
esy x make test
```

Build commands like `make` that would normally be executed by
themselves will need to be prefixed with `esy `.

For more, see the [esy documentation](https://github.com/esy-ocaml/esy).

### Troubleshooting

- Is the previous pinning unsuccessful? We might have updated a dependency; try `opam update` then `opam upgrade`.
- During the last `opam pin` step, make sure your local repo is clean. In particular, remove artifacts and `node_modules`. Otherwise the pinning might go stale or stall due to the big `node_modules`.

### Build

`make build`. **If this fails on your machine but master passes**, it means your setup wasn't right. Could you check if you followed the above installation steps? In particular, make sure you did `eval $(opam config env)` and sourced your shell environment (if you don't know how, just open a new shell tab and it'll be sourced usually).

The generated artifacts are in `_build`. All the binaries are in `_build/install/default/bin`.

### Test

To do some one-off tests, try `echo "let a = 1" | _build/install/default/bin/refmt`
<commit_msg>Improve docs for contributing via esy workflow.<commit_after># Core Reason

**See a list of easy tasks [here](https://github.com/facebook/reason/labels/GOOD%20FIRST%20TASK)**

## Contributor Setup

Thanks for considering contributing to Reason! Here's the setup you need:

### With opam

```sh
# On OSX, install opam via Homebrew:
brew update
brew install opam
# On Linux, see here (you will need opam >= 1.2.2): http://opam.ocaml.org/doc/Install.html

opam init
# Add this to your ~/.bashrc (or ~/.zshrc), then do `source ~/.bashrc`
#   eval $(opam config env)

opam update
opam switch 4.04.2
eval $(opam config env)
git clone https://github.com/facebook/reason.git
cd reason
opam pin add -y reason .
```

### With esy

[`esy`](https://github.com/esy/esy) is an `npm`-like workflow for developing and consuming
opam packages. It is still experimental, but if you're more familiar with `npm` than `opam`,
`esy` will likely be an easier way to contribute to Reason.
**Please file issues regarding `esy` at the [esy project](https://github.com/esy/esy) itself.**

```sh
# Make sure you have the latest esy 
npm remove -g esy
npm install -g esy@next
git clone https://github.com/facebook/reason.git
cd reason
esy install
esy build
```

##### Editors
- To use VSCode, just open the Reason project root, and `ocaml-language-server` automatically
works with `esy` projects, loading all the right dependencies.
- To use Vim/Emacs, start your editor using `esy vim` or `esy emacs`.

##### Running tests

You can run commands as if you had installed Reason by prefixing commands with `esy x` ("esy execute").
For example `esy x make test`

For more, see the [esy documentation](https://github.com/esy-ocaml/esy).

### Troubleshooting

- Is the previous pinning unsuccessful? We might have updated a dependency; try `opam update` then `opam upgrade`.
- During the last `opam pin` step, make sure your local repo is clean. In particular, remove artifacts and `node_modules`. Otherwise the pinning might go stale or stall due to the big `node_modules`.

### Build

`make build`. **If this fails on your machine but master passes**, it means your setup wasn't right. Could you check if you followed the above installation steps? In particular, make sure you did `eval $(opam config env)` and sourced your shell environment (if you don't know how, just open a new shell tab and it'll be sourced usually).

The generated artifacts are in `_build`. All the binaries are in `_build/install/default/bin`.

### Test

To do some one-off tests, try `echo "let a = 1" | _build/install/default/bin/refmt`

{'fraction_non_alphanumeric': 0.1042395104895105, 'fraction_numerical': 0.005244755244755245, 'mean_word_length': 4.165914221218961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6291631', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1337, 'n_words': 641}