2022-03-23 16:28:08 +00:00
_The current document was written quickly and not exhaustively, yet, it's unfinished. [Template here ](https://mozillascience.github.io/working-open-workshop/contributing/ )_
# Contributing to Squiggle
2022-04-12 05:41:36 +00:00
We welcome contributions from developers, especially people in react/typescript, rescript, and interpreters/parsers. We also are keen to hear issues filed by users!
2022-03-23 16:28:08 +00:00
2022-04-12 05:41:36 +00:00
Squiggle is currently pre-alpha.
2022-03-23 16:28:08 +00:00
# Quick links
2022-04-23 01:19:00 +00:00
- [Roadmap to the alpha ](https://github.com/orgs/quantified-uncertainty/projects/1 )
2022-03-23 16:28:08 +00:00
- The team presently communicates via the **EA Forecasting and Epistemics** slack (channels `#squiggle` and `#squiggle-ops` ), you can track down an invite by reaching out to Ozzie Gooen
- [Squiggle documentation ](https://www.squiggle-language.com/docs/Language )
- [Rescript documentation ](https://rescript-lang.org/docs/manual/latest/introduction )
2022-04-12 05:41:36 +00:00
- You can email `quinn@quantifieduncertainty.org` if you need assistance in onboarding or if you have questions
2022-03-23 16:28:08 +00:00
# Bug reports
2022-10-06 22:09:30 +00:00
Anyone (with a github account) can file an issue at any time. Please allow Slava, Sam, and Ozzie to triage, but otherwise just follow the suggestions in the issue templates.
2022-03-23 16:28:08 +00:00
# Project structure
2022-04-23 01:19:00 +00:00
Squiggle is a **monorepo** with three **packages** .
2022-04-12 05:41:36 +00:00
2022-03-23 16:28:08 +00:00
- **components** is where we improve reactive interfacing with Squiggle
2022-04-12 05:41:36 +00:00
- **squiggle-lang** is where the magic happens: probability distributions, the interpreter, etc.
2022-03-23 16:28:08 +00:00
- **website** is the site `squiggle-language.com`
# Deployment ops
2022-10-06 22:09:30 +00:00
We use Vercel, and it should only concern Slava, Sam, and Ozzie.
2022-03-23 16:28:08 +00:00
# Development environment, building, testing, dev server
2022-04-12 05:41:36 +00:00
You need `yarn` .
2022-03-23 16:28:08 +00:00
2022-04-12 05:41:36 +00:00
Being a monorepo, where packages are connected by dependency, it's important to follow `README.md` s closely. Each package has it's own `README.md` , which is where the bulk of information is.
2022-03-25 16:45:40 +00:00
2022-04-12 05:41:36 +00:00
We aspire for `ci.yaml` and `README.md` s to be in one-to-one correspondence.
2022-03-23 16:28:08 +00:00
2022-03-29 02:39:59 +00:00
## If you're on NixOS
2022-04-23 01:19:00 +00:00
You can't run `yarn` outside of a FHS shell. Additionally, you need to `patchelf` some things. A script does everything for you.
2022-04-12 05:41:36 +00:00
2022-03-29 02:39:59 +00:00
```sh
2022-04-23 01:19:00 +00:00
./nixos.sh
2022-03-29 02:39:59 +00:00
```
2022-04-23 16:25:33 +00:00
Reasons for this are comments in the script. Then, you should be able to do all the package-level `yarn run` commands/scripts.
2022-04-23 01:19:00 +00:00
# Try not to push directly to develop
2022-04-23 16:25:33 +00:00
If you absolutely must, please prefix your commit message with `hotfix: ` .
2022-03-29 02:39:59 +00:00
2022-03-23 16:28:08 +00:00
# Pull request protocol
2022-04-13 00:07:33 +00:00
Please work against `develop` branch. **Do not** work against `master` .
2022-04-12 19:00:47 +00:00
2022-10-06 22:09:30 +00:00
- For rescript code: Slava and Ozzie are reviewers
2022-04-12 19:00:47 +00:00
- For js or typescript code: Sam and Ozzie are reviewers
2022-10-06 22:09:30 +00:00
- For ops code (i.e. yaml, package.json): Slava and Sam are reviewers
2022-04-12 19:00:47 +00:00
Autopings are set up: if you are not autopinged, you are welcome to comment, but please do not use the formal review feature, send approvals, rejections, or merges.
2022-04-11 18:53:17 +00:00
# Code Quality
2022-04-13 00:07:33 +00:00
- Aim for at least 8/10\* quality in `/packages/squiggle-lang` , and 7/10 quality in `/packages/components` .
2022-04-11 18:53:17 +00:00
- If you submit a PR that is under a 7, for some reason, describe the reasoning for this in the PR.
* This quality score is subjective.
# Rescript Style
**Use `->` instead of `|>` **
Note: Our codebase used to use `|>` , so there's a lot of that in the system. We'll gradually change it.
**Use `x -> y -> z` instead of `let foo = y(x); let bar = z(foo)` **
**Don't use anonymous functions with over three lines**
Bad:
2022-04-13 00:07:33 +00:00
2022-04-11 18:53:17 +00:00
```rescript
foo
-> E.O.fmap(r => {
let a = 34;
let b = 35;
let c = 48;
r + a + b + c
}
```
2022-04-13 00:07:33 +00:00
2022-04-11 18:53:17 +00:00
Good:
2022-04-13 00:07:33 +00:00
2022-04-11 18:53:17 +00:00
```rescript
let addingFn = (r => {
let a = 34;
let b = 35;
let c = 48;
r + a + b + c
}
foo -> addingFn
```
**Write out types for everything, even if there's an interface file**
We'll try this for one month (ending May 5, 2022), then revisit.
**Use the Rescript optional default syntax**
Rescript is clever about function inputs. There's custom syntax for default and optional arguments. In the cases where this applies, use it.
From https://rescript-lang.org/docs/manual/latest/function:
2022-04-13 00:07:33 +00:00
2022-04-11 18:53:17 +00:00
```rescript
// radius can be omitted
let drawCircle = (~color, ~radius=?, ()) => {
setColor(color)
switch radius {
| None => startAt(1, 1)
| Some(r_) => startAt(r_, r_)
}
}
```
**Use named arguments**
If a function is called externally (in a different file), and has either:
2022-04-13 00:07:33 +00:00
2022-04-11 18:53:17 +00:00
1. Two arguments of the same type
2. Three paramaters or more.
**Module naming: Use x_y as module names**
2022-04-13 00:07:33 +00:00
For example: `Myname_Myproject_Add.res` . Rescript/Ocaml both require files to have unique names, so long names are needed to keep different parts separate from each other.
2022-04-11 18:53:17 +00:00
2022-04-12 00:24:46 +00:00
See [this page ](https://dev.to/yawaramin/a-modular-ocaml-project-structure-1ikd ) for more information. (Though note that they use two underscores, and we do one. We might refactor that later.
2022-04-11 18:53:17 +00:00
**Module naming: Don't rename modules**
2022-04-13 00:07:33 +00:00
We have some of this in the Reducer code, but generally discourage it.
2022-04-11 18:53:17 +00:00
**Use interface files (.resi) for files with very public interfaces**
2022-04-13 00:07:33 +00:00
### Recommended Rescript resources
2022-04-12 10:41:51 +00:00
2022-04-13 00:07:33 +00:00
- https://dev.to/yawaramin/a-modular-ocaml-project-structure-1ikd
- https://github.com/avohq/reasonml-code-style-guide
- https://cs.brown.edu/courses/cs017/content/docs/reasonml-style.pdf
- https://github.com/ostera/reason-design-patterns/