From b8159a88e07d4b81d43bece7cfdd7d909ddaa943 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 28 Mar 2022 22:39:59 -0400 Subject: [PATCH] Figured out patchelf hack for nixos users --- CONTRIBUTING.md | 9 ++++++++ flake.nix | 1 + .../squiggle-lang/__tests__/Symbolic_test.res | 23 +++++++++++++++++++ packages/squiggle-lang/package.json | 3 ++- .../squiggle-lang/src/rescript/utility/E.res | 4 ++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 packages/squiggle-lang/__tests__/Symbolic_test.res diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3694f142..a6b645f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,6 +36,15 @@ You need `yarn`. TODO: fill this out based on all the different packages scripts once they cool down. +## If you're on NixOS + +You'll need to run a command like this in order to get `yarn build` to run, especially in `packages/squiggle-lang`. +```sh +patchelf --set-interpreter $(patchelf --print-interpreter $(which mkdir)) ./node_modules/gentype/gentype.exe +``` + +See [here](https://github.com/NixOS/nixpkgs/issues/107375) + # Pull request protocol Please work against `staging` branch. **Do not** work against `master`. Please do not merge without approval from some subset of Quinn, Sam, and Ozzie; they will be auto-pinged. diff --git a/flake.nix b/flake.nix index fc4595b8..d39ba79a 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ yarn2nix nodePackages.npm nodejs + patchelf (pkgs.vscode-with-extensions.override { vscode = pkgs.vscodium; vscodeExtensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [ diff --git a/packages/squiggle-lang/__tests__/Symbolic_test.res b/packages/squiggle-lang/__tests__/Symbolic_test.res new file mode 100644 index 00000000..cdb178cd --- /dev/null +++ b/packages/squiggle-lang/__tests__/Symbolic_test.res @@ -0,0 +1,23 @@ +open Jest +open Expect +open Js.Array +open SymbolicDist +open E.Sp + +let makeTest = (~only=false, str, item1, item2) => + only + ? Only.test(str, () => expect(item1) -> toEqual(item2)) + : test(str, () => expect(item1) -> toEqual(item2)) + +let normalParams1: SymbolicDistTypes.normal = {mean: 5.0, stdev: 2.0} +let normalParams2: SymbolicDistTypes.normal = {mean: 10.0, stdev: 2.0} +let normalParams3: SymbolicDistTypes.normal = {mean: 20.0, stdev: 2.0} +let range20 = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0] +let forSparkline = (thisPdf, inps) => map(thisPdf, inps) + +describe("normal combine", () => { + let pdf1 = x => Normal.pdf(x, normalParams1) + let forSparkline1 = forSparkline(pdf1, range20) + let x = forSparkline1 -> toString -> sparkly -> Js.Console.log + makeTest("Spark1", 1, 0) +}) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index 6755d2d2..edb6803b 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -24,7 +24,8 @@ "mathjs": "10.4.1", "pdfast": "^0.2.0", "rationale": "0.2.0", - "rescript": "^9.1.4" + "rescript": "^9.1.4", + "sparkly": "6.0.0" }, "devDependencies": { "@glennsl/rescript-jest": "^0.9.0", diff --git a/packages/squiggle-lang/src/rescript/utility/E.res b/packages/squiggle-lang/src/rescript/utility/E.res index d17850fd..01c87a28 100644 --- a/packages/squiggle-lang/src/rescript/utility/E.res +++ b/packages/squiggle-lang/src/rescript/utility/E.res @@ -441,3 +441,7 @@ module JsArray = { |> Js.Array.map(Rationale.Option.toExn("Warning: This should not have happened")) let filter = Js.Array.filter } + +module Sp = { + @module("sparkly") @scope("sparkly") external sparkly: string => string = "sparkly" +}