From f2f885f269bb2ec4b96f3a8fc957825dbb780f36 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Wed, 13 Apr 2022 10:07:33 +1000 Subject: [PATCH] Hotfix Typescript checker failing --- CONTRIBUTING.md | 24 ++++++++++++------- .../src/rescript/TypescriptInterface.res | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 155907d8..f90fa60b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ See [here](https://github.com/NixOS/nixpkgs/issues/107375) # Pull request protocol -Please work against `develop` branch. **Do not** work against `master`. +Please work against `develop` branch. **Do not** work against `master`. - For rescript code: Quinn and Ozzie are reviewers - For js or typescript code: Sam and Ozzie are reviewers @@ -60,7 +60,8 @@ Please work against `develop` branch. **Do not** work against `master`. 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. # Code Quality -- Aim for at least 8/10* quality in ``/packages/squiggle-lang``, and 7/10 quality in ``/packages/components``. + +- Aim for at least 8/10\* quality in `/packages/squiggle-lang`, and 7/10 quality in `/packages/components`. - 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. @@ -74,6 +75,7 @@ Note: Our codebase used to use `|>`, so there's a lot of that in the system. We' **Don't use anonymous functions with over three lines** Bad: + ```rescript foo -> E.O.fmap(r => { @@ -83,7 +85,9 @@ Bad: r + a + b + c } ``` + Good: + ```rescript let addingFn = (r => { let a = 34; @@ -101,6 +105,7 @@ We'll try this for one month (ending May 5, 2022), then revisit. 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: + ```rescript // radius can be omitted let drawCircle = (~color, ~radius=?, ()) => { @@ -114,22 +119,23 @@ let drawCircle = (~color, ~radius=?, ()) => { **Use named arguments** If a function is called externally (in a different file), and has either: + 1. Two arguments of the same type 2. Three paramaters or more. **Module naming: Use x_y as module names** -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. +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. 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. **Module naming: Don't rename modules** -We have some of this in the Reducer code, but generally discourage it. +We have some of this in the Reducer code, but generally discourage it. **Use interface files (.resi) for files with very public interfaces** -### Recommended Rescript resources -- 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/ +### Recommended Rescript resources +- 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/ diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index a706bdd2..2683edb1 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -32,7 +32,7 @@ let makeSampleSetDist = SampleSetDist.make let evaluate = Reducer.evaluate @genType -type expressionValue = Reducer_Expression.expressionValue +type expressionValue = ReducerInterface_ExpressionValue.expressionValue @genType type errorValue = Reducer_ErrorValue.errorValue