Compare commits

...

765 Commits

Author SHA1 Message Date
Vyacheslav Matyukhin
9e2eace05e
Merge pull request #1231 from quantified-uncertainty/project-in-editors
Project in editors and remove warnings
2022-10-14 18:06:49 +03:00
Vyacheslav Matyukhin
a0000cd179
Merge branch 'develop' into project-in-editors 2022-10-13 03:36:08 +04:00
Vyacheslav Matyukhin
56771820aa
Merge pull request #965 from quantified-uncertainty/experiment-10.0rc1
bump `rescript` and `@rescript/std` to `10.0.1`
2022-10-13 02:25:23 +03:00
Vyacheslav Matyukhin
33f0647be8
Merge pull request #1260 from quantified-uncertainty/drop-bisect-ppx
remove bisect_ppx
2022-10-13 02:24:53 +03:00
cab
878c6f3d4b
Removed nixos.sh
Also added a note in README.md for NixOS users
2022-10-13 01:03:16 +04:00
Vyacheslav Matyukhin
4cd045b9c8
format rescript 2022-10-12 20:11:28 +04:00
Vyacheslav Matyukhin
a617ec0436
update coverage name in prettierignore 2022-10-12 20:00:27 +04:00
Vyacheslav Matyukhin
80cc20ac72
fix tests 2022-10-12 19:49:14 +04:00
Vyacheslav Matyukhin
666524a36a
Merge branch 'drop-bisect-ppx' into experiment-10.0rc1 2022-10-12 19:36:23 +04:00
Vyacheslav Matyukhin
2ed3633fe5
coverage:local echo note 2022-10-12 19:31:44 +04:00
Vyacheslav Matyukhin
deb88c60fb
Merge branch 'develop' into drop-bisect-ppx 2022-10-12 19:12:25 +04:00
Vyacheslav Matyukhin
838d13086a
remove nyc dependency, jest is enough for coverage 2022-10-12 19:09:17 +04:00
cab
11e80941bc
nix: remove bisect_ppx from build 2022-10-12 18:32:08 +04:00
dependabot[bot]
e11cca658e
Merge pull request #1248 from quantified-uncertainty/dependabot/npm_and_yarn/jest-environment-jsdom-29.1.2 2022-10-12 12:38:35 +00:00
dependabot[bot]
2d0949c3f6
⬆️ Bump jest-environment-jsdom from 29.0.3 to 29.1.2
Bumps [jest-environment-jsdom](https://github.com/facebook/jest/tree/HEAD/packages/jest-environment-jsdom) from 29.0.3 to 29.1.2.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v29.1.2/packages/jest-environment-jsdom)

---
updated-dependencies:
- dependency-name: jest-environment-jsdom
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-12 12:30:46 +00:00
Vyacheslav Matyukhin
8dac70082c
remove bisect_ppx 2022-10-12 16:21:07 +04:00
Vyacheslav Matyukhin
d7e548d84e
Merge pull request #1259 from quantified-uncertainty/fetch-depth-for-coverage
fetch-depth for coverage job
2022-10-12 15:00:30 +03:00
dependabot[bot]
2cd22fa8e5
Merge pull request #1245 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.5.3 2022-10-12 11:48:03 +00:00
dependabot[bot]
21e4908fbf
Merge pull request #1247 from quantified-uncertainty/dependabot/npm_and_yarn/web-vitals-3.0.3 2022-10-12 11:40:54 +00:00
dependabot[bot]
07802ff151
Merge pull request #1252 from quantified-uncertainty/dependabot/npm_and_yarn/react-hook-form-7.37.0 2022-10-12 11:40:33 +00:00
dependabot[bot]
f079c1f6ef
Merge pull request #1249 from quantified-uncertainty/dependabot/npm_and_yarn/ts-jest-29.0.3 2022-10-12 11:40:25 +00:00
dependabot[bot]
91a3a066c2
Merge pull request #1251 from quantified-uncertainty/dependabot/npm_and_yarn/chalk-5.1.0 2022-10-12 11:40:24 +00:00
dependabot[bot]
8608faa79b
Merge pull request #1250 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.8.3 2022-10-12 11:39:53 +00:00
Vyacheslav Matyukhin
e076bd935f
fetch-depth for coverage job 2022-10-12 15:35:42 +04:00
dependabot[bot]
fdcdf2fa3d
Merge pull request #1253 from quantified-uncertainty/dependabot/npm_and_yarn/jsdom-20.0.1 2022-10-12 11:34:14 +00:00
Vyacheslav Matyukhin
2d9fea4f21
Merge pull request #1244 from quantified-uncertainty/squiggle-cli-docs-2022-10-10
tweak: Add more verbose documentation to the cli README
2022-10-12 10:59:50 +03:00
Vyacheslav Matyukhin
f6322fad13
Merge pull request #1255 from quantified-uncertainty/fix-docs-truncate-right
Should be truncateRight
2022-10-12 10:36:50 +03:00
Sam Nolan
699960d220 Should be truncateRight 2022-10-12 14:30:38 +11:00
Ozzie Gooen
ac0cc01852 Ran formatting 2022-10-11 18:58:35 -07:00
Ozzie Gooen
c65a9d3ae6
Merge pull request #1238 from quantified-uncertainty/fix-manual-run
Fix manual run
2022-10-11 14:20:34 -07:00
dependabot[bot]
113be7d8cb
⬆️ Bump jsdom from 20.0.0 to 20.0.1
Bumps [jsdom](https://github.com/jsdom/jsdom) from 20.0.0 to 20.0.1.
- [Release notes](https://github.com/jsdom/jsdom/releases)
- [Changelog](https://github.com/jsdom/jsdom/blob/master/Changelog.md)
- [Commits](https://github.com/jsdom/jsdom/compare/20.0.0...20.0.1)

---
updated-dependencies:
- dependency-name: jsdom
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:37:48 +00:00
dependabot[bot]
2596d1a695
⬆️ Bump react-hook-form from 7.36.1 to 7.37.0
Bumps [react-hook-form](https://github.com/react-hook-form/react-hook-form) from 7.36.1 to 7.37.0.
- [Release notes](https://github.com/react-hook-form/react-hook-form/releases)
- [Changelog](https://github.com/react-hook-form/react-hook-form/blob/master/CHANGELOG.md)
- [Commits](https://github.com/react-hook-form/react-hook-form/compare/v7.36.1...v7.37.0)

---
updated-dependencies:
- dependency-name: react-hook-form
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:34:57 +00:00
dependabot[bot]
41153988d8
⬆️ Bump chalk from 5.0.1 to 5.1.0
Bumps [chalk](https://github.com/chalk/chalk) from 5.0.1 to 5.1.0.
- [Release notes](https://github.com/chalk/chalk/releases)
- [Commits](https://github.com/chalk/chalk/compare/v5.0.1...v5.1.0)

---
updated-dependencies:
- dependency-name: chalk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:34:54 +00:00
dependabot[bot]
8c7340185c
⬆️ Bump @types/node from 18.8.0 to 18.8.3
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.8.0 to 18.8.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:34:12 +00:00
dependabot[bot]
bd4250c793
⬆️ Bump ts-jest from 29.0.2 to 29.0.3
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 29.0.2 to 29.0.3.
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.0.2...v29.0.3)

---
updated-dependencies:
- dependency-name: ts-jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:33:01 +00:00
dependabot[bot]
c204ce37ad
⬆️ Bump web-vitals from 3.0.2 to 3.0.3
Bumps [web-vitals](https://github.com/GoogleChrome/web-vitals) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/GoogleChrome/web-vitals/releases)
- [Changelog](https://github.com/GoogleChrome/web-vitals/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleChrome/web-vitals/compare/v3.0.2...v3.0.3)

---
updated-dependencies:
- dependency-name: web-vitals
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:31:36 +00:00
dependabot[bot]
344ee0ce17
⬆️ Bump framer-motion from 7.5.1 to 7.5.3
Bumps [framer-motion](https://github.com/framer/motion) from 7.5.1 to 7.5.3.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.5.1...v7.5.3)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 15:28:06 +00:00
71db023f0c tweak: Add more verbose documentation to the cli README 2022-10-10 14:24:42 +01:00
Vyacheslav Matyukhin
bd94e51b31
Merge pull request #1240 from quantified-uncertainty/1109-fix
note that SquiggleEditorWithImportedBindings is broken (fixes #1109)
2022-10-10 12:35:36 +03:00
Vyacheslav Matyukhin
964e95f598
Merge pull request #1242 from quantified-uncertainty/changelog
Changelog page
2022-10-10 12:35:24 +03:00
Sam Nolan
98454a87b5 Get projects working in Playgrounds 2022-10-10 14:23:04 +11:00
Vyacheslav Matyukhin
5efb66c3e5
changelog page 2022-10-09 15:27:47 +04:00
Vyacheslav Matyukhin
2389dff69a
note that SquiggleEditorWithImportedBindings is broken (fixes #1109) 2022-10-09 15:04:45 +04:00
Vyacheslav Matyukhin
1ea3c975d5
Merge pull request #1233 from quantified-uncertainty/turborepo
Turborepo
2022-10-09 13:03:20 +03:00
Vyacheslav Matyukhin
1e13dc71f1
Merge branch 'develop' into turborepo 2022-10-09 13:47:41 +04:00
Vyacheslav Matyukhin
a515d9560c
Merge pull request #1232 from cab404/cab/esbuild-vsix
vscode-ext: move to esbuild bundling, cleanup
2022-10-09 12:42:38 +03:00
cab
9582be7331
lint 2022-10-09 13:28:59 +04:00
Vyacheslav Matyukhin
827bb43354
fix #1236 2022-10-09 13:15:51 +04:00
Vyacheslav Matyukhin
27c4c9acf2
playground and autorun tests (incomplete) 2022-10-09 13:15:26 +04:00
cab
28e944dd04
tsconfig: switch includes 2022-10-08 22:06:26 +04:00
Vyacheslav Matyukhin
9992d7da1a
empty outputs of lint and test 2022-10-08 21:34:31 +04:00
Vyacheslav Matyukhin
de532c72d6
custom squiggle-components outputs; never cache coverage 2022-10-08 21:15:37 +04:00
Vyacheslav Matyukhin
fd6c4ae1de
yarn in CI tuning 2022-10-08 19:55:57 +04:00
Vyacheslav Matyukhin
5621567af2
nudge CI to check caching 2022-10-08 19:55:33 +04:00
Vyacheslav Matyukhin
000b7a6248
change coverage:local order too 2022-10-08 19:46:59 +04:00
cab
13a54f3e3d
vscode-ext: move to esbuild bundling, cleanup
This removes node_modules from dependencies all together fixing long
time issue with yarn putting only a subset of dependencies in the
extension source tree.

It as well makes extension footprint 15x smaller. (down to 2.3Mb)

Kinda fixes #1162? It actually un-patches vsce though — it really is not
an issue it should be solving :D
2022-10-08 19:24:30 +04:00
Vyacheslav Matyukhin
4abdb69f23
fix coverage? 2022-10-08 19:24:12 +04:00
Vyacheslav Matyukhin
ed86fd9f77
separate job for coverage, fix infinite loop 2022-10-08 19:13:44 +04:00
Vyacheslav Matyukhin
bcc5b5846f
list all turbo outputs for squiggle-lang 2022-10-08 19:02:31 +04:00
Vyacheslav Matyukhin
da8db5db9c
call yarn 2022-10-08 18:37:34 +04:00
Vyacheslav Matyukhin
d7c6996284
vscode-ext depends on old 0.2.11 lang again for parsing; more turbo tuning 2022-10-08 18:16:54 +04:00
Vyacheslav Matyukhin
b7d56a3f1f
turbo tuning 2022-10-08 18:03:47 +04:00
Vyacheslav Matyukhin
d037913e7c
npx turbo 2022-10-08 17:45:59 +04:00
Vyacheslav Matyukhin
2c01c77646
Merge branch 'develop' into turborepo 2022-10-08 17:44:52 +04:00
Vyacheslav Matyukhin
7493f2e2e5
update vercel configs to use turbo 2022-10-08 17:41:58 +04:00
Vyacheslav Matyukhin
07fcbeb568
more turbo; rewrite and simplify github CI 2022-10-08 17:28:43 +04:00
Sam Nolan
0f8e7ce6b6 Project in editors and remove warnings 2022-10-08 16:23:58 +11:00
Vyacheslav Matyukhin
cc846aa74c
turborepo 2022-10-08 05:19:15 +04:00
Vyacheslav Matyukhin
214a54e57e
prettierignore generated files 2022-10-08 05:18:44 +04:00
Vyacheslav Matyukhin
eaa7d38428
Merge pull request #1230 from quantified-uncertainty/merge-master-to-develop
Merge master to develop
2022-10-08 04:07:54 +03:00
Vyacheslav Matyukhin
96e0418f60
Merge branch 'master' into remerge-develop-from-master 2022-10-08 04:45:30 +04:00
Vyacheslav Matyukhin
2bb9622edd
Merge pull request #1172 from quantified-uncertainty/error-locations
Error locations and stacktraces
2022-10-08 03:41:55 +03:00
Vyacheslav Matyukhin
76ea024342
Merge branch 'develop' into error-locations 2022-10-08 04:29:57 +04:00
Vyacheslav Matyukhin
d5f0a6bcf8
Merge branch 'develop' into error-locations 2022-10-08 04:12:19 +04:00
Vyacheslav Matyukhin
b2c10924cd
Merge pull request #1142 from quantified-uncertainty/project-component
Add projects to components
2022-10-08 02:58:48 +03:00
Vyacheslav Matyukhin
7bfe52c2d3
Merge pull request #1228 from quantified-uncertainty/vercel-on-master
Vercel on master
2022-10-07 15:45:04 +03:00
Vyacheslav Matyukhin
d6a48d9cb9
disable ignoreCommand in vercel.json for now 2022-10-07 16:23:28 +04:00
Vyacheslav Matyukhin
4efd2c9e05
remove special dependabot case from ignoreCommand 2022-10-07 16:09:37 +04:00
Vyacheslav Matyukhin
0ab03eca96
fix broken link in docs 2022-10-07 16:09:35 +04:00
Vyacheslav Matyukhin
9107b241f5
replace netlify with vercel; update CONTRIBUTING.md 2022-10-07 16:09:32 +04:00
Vyacheslav Matyukhin
c1e67066aa
vercel.json configs 2022-10-07 16:09:30 +04:00
Vyacheslav Matyukhin
ccdcb1a72b
Merge pull request #1227 from quantified-uncertainty/vercel
Move to Vercel
2022-10-07 15:07:29 +03:00
Sam Nolan
85a8c06107 Respond to review comments 2022-10-07 11:18:13 +11:00
Vyacheslav Matyukhin
871254dff9
nudging Vercel to check ignoreCommand 2022-10-07 02:54:27 +04:00
Vyacheslav Matyukhin
ff5e0dd14c
remove special dependabot case from ignoreCommand 2022-10-07 02:47:43 +04:00
Vyacheslav Matyukhin
f6e69dad38
fix broken link in docs 2022-10-07 02:20:33 +04:00
Vyacheslav Matyukhin
7e4139acb3
replace netlify with vercel; update CONTRIBUTING.md 2022-10-07 02:09:30 +04:00
Vyacheslav Matyukhin
af885ef58f
vercel.json configs 2022-10-07 01:38:38 +04:00
Vyacheslav Matyukhin
061d785996
Merge pull request #1226 from skejeton/sampleset-fix-error-message
SampleSet.fromList fix error message
2022-10-06 23:38:18 +03:00
skejeton
355ff199c1
fix: merge 2022-10-06 23:31:34 +03:00
skejeton
a48efc23b0 Merge branch 'develop' of https://github.com/skejeton/squiggle into sampleset-fix-error-message 2022-10-06 23:24:45 +03:00
skejeton
2c5511efc1
fix: SampleSet.fromList giving bad error message #1186 2022-10-06 23:19:43 +03:00
Vyacheslav Matyukhin
f39c69a2d4
Merge pull request #1225 from quantified-uncertainty/epic-0.5.0
Remerge epic-0.5.0 to develop
2022-10-06 22:51:33 +03:00
Vyacheslav Matyukhin
b4c649d03b
Merge branch 'develop' into epic-0.5.0 2022-10-06 23:33:40 +04:00
Vyacheslav Matyukhin
8184396d3e
Merge pull request #1224 from skejeton/list-length
feature: List.length
2022-10-06 22:05:40 +03:00
skejeton
1a131828e6
fix: List.length requiresNamespace wasn't set to true 2022-10-06 21:39:44 +03:00
skejeton
92d3c761fa
feature: List.length 2022-10-06 16:49:33 +03:00
Sam Nolan
42e9ad810d Format typescript 2022-10-06 13:40:31 +11:00
Sam Nolan
a718b369c2 Make code neccesary in hook 2022-10-06 13:38:59 +11:00
Vyacheslav Matyukhin
bac954d949
nudge vercel CI 2022-10-06 02:42:50 +04:00
Ozzie Gooen
1474630af8
Merge pull request #1216 from david-mears-2/suffix-numbers
English language pedantry: Fix use of 'prefix' in docs
2022-10-05 11:01:33 -07:00
Ozzie Gooen
ffc6cd3840
Merge pull request #1222 from quantified-uncertainty/no-dark-mode
Disable dark mode
2022-10-05 11:01:02 -07:00
Vyacheslav Matyukhin
b5c5b81db4
nudge CI 2022-10-05 19:56:48 +04:00
Vyacheslav Matyukhin
77dbb223f9
disable dark mode 2022-10-05 19:36:48 +04:00
Vyacheslav Matyukhin
19a44eb12f
fix #1214 2022-10-05 19:19:22 +04:00
Vyacheslav Matyukhin
8cbbdf5489
stacktrace test 2022-10-05 18:07:37 +04:00
Vyacheslav Matyukhin
2d0e6432cd
fix #1199 2022-10-05 17:10:53 +04:00
Vyacheslav Matyukhin
0137b44689
more cleanups, some tests 2022-10-05 16:22:29 +04:00
Vyacheslav Matyukhin
6055320aa2
more cleanups 2022-10-05 15:56:13 +04:00
Vyacheslav Matyukhin
6463c4db5a
minor cleanups 2022-10-05 15:49:16 +04:00
Vyacheslav Matyukhin
a45d6c6c57
format 2022-10-05 05:22:00 +04:00
Vyacheslav Matyukhin
9f1c5affc4
ts fix 2022-10-05 05:21:39 +04:00
Vyacheslav Matyukhin
234ebe2103
locations for syntax errors 2022-10-05 05:17:30 +04:00
Sam Nolan
f19c096e7c Remove needsClean 2022-10-05 12:06:03 +11:00
Vyacheslav Matyukhin
298492b3b8
Merge branch 'develop' into error-locations 2022-10-05 05:00:02 +04:00
Sam Nolan
bb6fece694 Restrict interfaces with projects for components 2022-10-05 11:57:32 +11:00
Vyacheslav Matyukhin
26dbd29ec8
framestack reimplemented 2022-10-05 04:51:23 +04:00
David Mears
c11fbda8b0
English language: Fix use of 'prefix' in docs
prefixes come before, postfixes come after, suffixes is a generic term
2022-10-04 21:33:40 +01:00
Vyacheslav Matyukhin
d60792aa93
Merge pull request #1201 from quantified-uncertainty/issue-to-operator-priority
to operator priority
2022-10-04 15:23:44 +03:00
Umur Ozkul
39cc4a32ca to operator priority test 2022-10-04 13:04:57 +02:00
Umur Ozkul
1bb9e75ed3 Merge branch 'develop' into issue-to-operator-priority 2022-10-04 13:01:48 +02:00
Sam Nolan
b512751110 Update yarn.lock 2022-10-04 14:03:35 +11:00
Sam Nolan
b412eee646 Add tests for different types of cleanup 2022-10-04 13:38:15 +11:00
Sam Nolan
a0e3f70dbb Add cleanup tests 2022-10-04 12:22:41 +11:00
Sam Nolan
2be9d274f2 Merge branch 'develop' into project-component 2022-10-04 11:07:20 +11:00
Sam Nolan
60f464ebac
Merge pull request #1188 from quantified-uncertainty/component-testing
Component testing
2022-10-04 11:05:29 +11:00
Sam Nolan
2ed234b83b Merge branch 'develop' into component-testing 2022-10-04 10:35:48 +11:00
Sam Nolan
be8dbf8aa1 Merge branch 'remove-sources' into develop 2022-10-04 10:24:07 +11:00
Sam Nolan
9caee0fecd
Merge pull request #1167 from quantified-uncertainty/remove-sources
Add removeSource to project
2022-10-04 10:20:40 +11:00
Sam Nolan
156d98c979 Add comment about when width is not finite 2022-10-04 09:54:43 +11:00
Sam Nolan
20382a5476 Update incorrect comments 2022-10-04 09:47:17 +11:00
dependabot[bot]
d13b14b18c
Merge pull request #1205 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.8.0 2022-10-03 14:58:49 +00:00
dependabot[bot]
48e19000f2
Merge pull request #1208 from quantified-uncertainty/dependabot/github_actions/fkirc/skip-duplicate-actions-5.2.0 2022-10-03 14:51:34 +00:00
dependabot[bot]
e21eedd579
⬆️ Bump @types/node from 18.7.22 to 18.8.0
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.22 to 18.8.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:50:50 +00:00
dependabot[bot]
ab8f11abe0
Merge pull request #1207 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-4.8.4 2022-10-03 14:47:30 +00:00
dependabot[bot]
c95152f4f5
Merge pull request #1206 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.5.1 2022-10-03 14:45:05 +00:00
dependabot[bot]
8dbdc89fa0
Merge pull request #1204 from quantified-uncertainty/dependabot/npm_and_yarn/types/lodash-4.14.186 2022-10-03 14:42:56 +00:00
dependabot[bot]
42c67c549a
⬆️ Bump fkirc/skip-duplicate-actions from 5.1.0 to 5.2.0
Bumps [fkirc/skip-duplicate-actions](https://github.com/fkirc/skip-duplicate-actions) from 5.1.0 to 5.2.0.
- [Release notes](https://github.com/fkirc/skip-duplicate-actions/releases)
- [Commits](https://github.com/fkirc/skip-duplicate-actions/compare/v5.1.0...v5.2.0)

---
updated-dependencies:
- dependency-name: fkirc/skip-duplicate-actions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:42:35 +00:00
dependabot[bot]
344fb8eba4
Merge pull request #1202 from quantified-uncertainty/dependabot/npm_and_yarn/headlessui/react-1.7.3 2022-10-03 14:41:25 +00:00
dependabot[bot]
02eb10f092
⬆️ Bump typescript from 4.8.3 to 4.8.4
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.8.3 to 4.8.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.8.3...v4.8.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:38:15 +00:00
dependabot[bot]
058ea0a6bb
Merge pull request #1203 from quantified-uncertainty/dependabot/npm_and_yarn/commander-9.4.1 2022-10-03 14:37:31 +00:00
dependabot[bot]
9f57645c90
⬆️ Bump framer-motion from 7.4.0 to 7.5.1
Bumps [framer-motion](https://github.com/framer/motion) from 7.4.0 to 7.5.1.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.4.0...v7.5.1)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:37:08 +00:00
dependabot[bot]
fd5ef6720e
⬆️ Bump @types/lodash from 4.14.185 to 4.14.186
Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.14.185 to 4.14.186.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash)

---
updated-dependencies:
- dependency-name: "@types/lodash"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:34:00 +00:00
dependabot[bot]
545d74131c
⬆️ Bump commander from 9.4.0 to 9.4.1
Bumps [commander](https://github.com/tj/commander.js) from 9.4.0 to 9.4.1.
- [Release notes](https://github.com/tj/commander.js/releases)
- [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tj/commander.js/compare/v9.4.0...v9.4.1)

---
updated-dependencies:
- dependency-name: commander
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:32:55 +00:00
dependabot[bot]
f5d1777ce8
⬆️ Bump @headlessui/react from 1.7.2 to 1.7.3
Bumps [@headlessui/react](https://github.com/tailwindlabs/headlessui/tree/HEAD/packages/@headlessui-react) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/tailwindlabs/headlessui/releases)
- [Changelog](https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/headlessui/commits/@headlessui/react@v1.7.3/packages/@headlessui-react)

---
updated-dependencies:
- dependency-name: "@headlessui/react"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 14:32:28 +00:00
Umur Ozkul
54cbcea5d6 to operator priority
higher than logical operators, lower than all other operators
2022-10-03 16:16:00 +02:00
Vyacheslav Matyukhin
5f5334ed8e
Merge pull request #1200 from quantified-uncertainty/sampleset-doc-fix
fix SampleSet.fromDist docs (fixes #1039)
2022-10-03 02:45:38 +03:00
Vyacheslav Matyukhin
f33323c4d7
fix SampleSet.fromDist docs (fixes #1039) 2022-10-03 03:29:02 +04:00
Vyacheslav Matyukhin
54d52e4d91
Merge pull request #1193 from quantified-uncertainty/develop
Disable algolia search on master
2022-10-02 17:02:18 +03:00
Vyacheslav Matyukhin
7856669239
Merge pull request #1191 from quantified-uncertainty/disable-search
Disable algolia search
2022-10-02 16:54:20 +03:00
Vyacheslav Matyukhin
ca91604ce2
disable algolia search 2022-10-02 17:47:49 +04:00
Vyacheslav Matyukhin
b1639bf62c
Merge pull request #1190 from quantified-uncertainty/develop
0.5.0
2022-10-02 14:39:11 +03:00
Vyacheslav Matyukhin
d5a0e0fe6c
0.5 release versions 2022-10-02 15:30:17 +04:00
Vyacheslav Matyukhin
ef3069c665
Merge pull request #1185 from quantified-uncertainty/epic-0.5.0
0.5.0 overhaul
2022-10-02 13:48:30 +03:00
Vyacheslav Matyukhin
c47d5b4e62
remove SquigglePartial story (was broken since 0.4) 2022-10-02 14:28:03 +04:00
Vyacheslav Matyukhin
a764f3075c
WIP (broken) 2022-10-02 14:04:45 +04:00
dependabot[bot]
832bfd82dd
Merge pull request #1176 from quantified-uncertainty/dependabot/npm_and_yarn/ts-loader-9.4.1 2022-09-30 15:37:55 +00:00
dependabot[bot]
6819e6d38d
⬆️ Bump ts-loader from 9.4.0 to 9.4.1
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.4.0 to 9.4.1.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.4.0...9.4.1)

---
updated-dependencies:
- dependency-name: ts-loader
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-30 15:28:46 +00:00
Sam Nolan
afaabdb5b3 Fix github CI grammar 2022-09-30 15:31:39 +10:00
Sam Nolan
9321fe5681 Add component testing to CI 2022-09-30 15:27:07 +10:00
Sam Nolan
056bbb65f4 Merge branch 'epic-0.5.0' into component-testing 2022-09-30 15:21:29 +10:00
Sam Nolan
5d38871e25 Add component testing and remove vega warnings 2022-09-30 15:19:49 +10:00
Sam Nolan
c5370dd799 Merge branch 'epic-0.5.0' into remove-sources 2022-09-30 11:51:39 +10:00
Sam Nolan
6cd368ba7d Format components 2022-09-30 10:38:48 +10:00
Sam Nolan
8477b0c5f7 Format Rescript + fix ts error 2022-09-30 10:36:42 +10:00
Sam Nolan
ecf9d43401 Format rescript 2022-09-30 10:34:15 +10:00
Sam Nolan
32cd765969 Merge branch 'develop' into epic-0.5.0 2022-09-30 10:30:36 +10:00
Sam Nolan
7bff9bafb8 Merge branch 'develop' into project-component 2022-09-30 10:23:42 +10:00
Sam Nolan
b00edc78f9 Merge branch 'develop' into remove-sources 2022-09-30 10:22:40 +10:00
Sam Nolan
33c16bd072 Start component testing 2022-09-30 10:22:14 +10:00
Vyacheslav Matyukhin
184584c9f3
CallStack, location -> frame, WIP 2022-09-29 19:48:31 +04:00
dependabot[bot]
46e689af51
Merge pull request #1182 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.4.0 2022-09-28 21:58:04 +00:00
Ozzie Gooen
d001b3c245
Add epic-0.5.0 to pull_request branch 2022-09-28 09:52:45 -04:00
Sam Nolan
c9e5b11416 Format rescript 2022-09-28 14:16:05 +10:00
Vyacheslav Matyukhin
4c56b2fd07
implement error markers in editor 2022-09-27 02:29:00 +04:00
dependabot[bot]
c44c4baa5f
Merge pull request #1177 from quantified-uncertainty/dependabot/npm_and_yarn/webpack-dev-server-4.11.1 2022-09-26 18:51:49 +00:00
dependabot[bot]
67e8f1a196
Merge pull request #1180 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.22 2022-09-26 18:33:57 +00:00
dependabot[bot]
acae4bfd3e
Merge pull request #1174 from quantified-uncertainty/dependabot/npm_and_yarn/react-hook-form-7.36.1 2022-09-26 18:29:59 +00:00
dependabot[bot]
3098cf7b71
⬆️ Bump @types/node from 18.7.18 to 18.7.22
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.18 to 18.7.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 18:24:08 +00:00
dependabot[bot]
bc1bfeb5cd
⬆️ Bump webpack-dev-server from 4.11.0 to 4.11.1
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.11.0 to 4.11.1.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.11.0...v4.11.1)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 18:24:06 +00:00
dependabot[bot]
dd20b52ee8
Merge pull request #1179 from quantified-uncertainty/dependabot/npm_and_yarn/fast-check-3.1.4 2022-09-26 18:22:17 +00:00
dependabot[bot]
28ba89b8c8
⬆️ Bump react-hook-form from 7.35.0 to 7.36.1
Bumps [react-hook-form](https://github.com/react-hook-form/react-hook-form) from 7.35.0 to 7.36.1.
- [Release notes](https://github.com/react-hook-form/react-hook-form/releases)
- [Changelog](https://github.com/react-hook-form/react-hook-form/blob/master/CHANGELOG.md)
- [Commits](https://github.com/react-hook-form/react-hook-form/compare/v7.35.0...v7.36.1)

---
updated-dependencies:
- dependency-name: react-hook-form
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 18:21:37 +00:00
dependabot[bot]
f02e522a2e
⬆️ Bump fast-check from 3.1.3 to 3.1.4
Bumps [fast-check](https://github.com/dubzzz/fast-check/tree/HEAD/packages/fast-check) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/dubzzz/fast-check/releases)
- [Changelog](https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/CHANGELOG.md)
- [Commits](https://github.com/dubzzz/fast-check/commits/v3.1.4/packages/fast-check)

---
updated-dependencies:
- dependency-name: fast-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 18:12:34 +00:00
dependabot[bot]
730851379e
⬆️ Bump framer-motion from 7.3.5 to 7.4.0
Bumps [framer-motion](https://github.com/framer/motion) from 7.3.5 to 7.4.0.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.3.5...v7.4.0)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 18:08:09 +00:00
Quinn
cca9786b8a
Merge pull request #1178 from quantified-uncertainty/dependabot/github_actions/fkirc/skip-duplicate-actions-5.1.0
⬆️ Bump fkirc/skip-duplicate-actions from 4.0.0 to 5.1.0
2022-09-26 13:53:51 -04:00
Quinn
4521d03664
Merge pull request #1181 from quantified-uncertainty/dependabot/npm_and_yarn/types/react-18.0.21
⬆️ Bump @types/react from 18.0.20 to 18.0.21
2022-09-26 13:52:32 -04:00
Ozzie Gooen
6d1bc4009f
Merge pull request #1171 from quantified-uncertainty/sampleset-cdf 2022-09-26 12:23:24 -04:00
Ozzie Gooen
7498eb4925
Merge pull request #1170 from quantified-uncertainty/OAGr-remove-Function
Delete Function.md
2022-09-26 10:57:12 -04:00
dependabot[bot]
bf3f71c721
⬆️ Bump @types/react from 18.0.20 to 18.0.21
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.0.20 to 18.0.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 14:38:43 +00:00
dependabot[bot]
1548033fb4
⬆️ Bump fkirc/skip-duplicate-actions from 4.0.0 to 5.1.0
Bumps [fkirc/skip-duplicate-actions](https://github.com/fkirc/skip-duplicate-actions) from 4.0.0 to 5.1.0.
- [Release notes](https://github.com/fkirc/skip-duplicate-actions/releases)
- [Commits](https://github.com/fkirc/skip-duplicate-actions/compare/v4.0.0...v5.1.0)

---
updated-dependencies:
- dependency-name: fkirc/skip-duplicate-actions
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 14:36:11 +00:00
Vyacheslav Matyukhin
845d38e375
top-level SqError; expose stacktrace in TS API 2022-09-26 16:27:45 +04:00
Sam Nolan
b2ae31742e Format rescript 2022-09-26 14:20:00 +10:00
Sam Nolan
96a0d9c489 Add removeSource to project 2022-09-26 14:14:37 +10:00
Sam Nolan
b4fbd1f8e8 Format and ts errors 2022-09-26 13:55:22 +10:00
Sam Nolan
64f9c9ddfc Merge branch 'overhaul' into project-component 2022-09-26 13:35:12 +10:00
Vyacheslav Matyukhin
69b32d0b93
refactor into SqError 2022-09-26 04:44:08 +04:00
Vyacheslav Matyukhin
111dd5535c
move location to Reducer_Peggy_Parse, separate parse errors 2022-09-26 03:42:34 +04:00
Vyacheslav Matyukhin
41574e08c9
error stacktraces and locations (initial take, WIP) 2022-09-25 03:16:14 +04:00
Vyacheslav Matyukhin
d3bc08ab9d
remove all type-related code 2022-09-24 21:26:44 +04:00
Vyacheslav Matyukhin
c337211af6
rename tests 2022-09-24 20:39:09 +04:00
Vyacheslav Matyukhin
2e9dabccd9
Merge branch 'develop' into overhaul 2022-09-24 20:29:00 +04:00
Vyacheslav Matyukhin
bfcea1df02
implement SampleSet.cdf 2022-09-24 19:18:30 +04:00
Ozzie Gooen
f82cff9c19
Delete Function.md 2022-09-24 10:13:20 -04:00
Sam Nolan
3ae442ee1f Fix some collection issues 2022-09-22 10:02:15 +10:00
Sam Nolan
94b4744bea Merge branch 'develop' into project-component 2022-09-22 08:30:57 +10:00
Vyacheslav Matyukhin
9ddd1bfae0
Merge pull request #1166 from quantified-uncertainty/fix-multiple-plots
Fixes multiple plots
2022-09-21 22:50:29 +04:00
Sam Nolan
46fd5900d2 Make distributions required 2022-09-21 16:14:06 +10:00
Sam Nolan
d619794cf6 Merge branch 'develop' into project-component 2022-09-21 16:09:58 +10:00
Sam Nolan
b7d634de86 Rename import as prefix to real source name 2022-09-21 13:40:15 +10:00
Sam Nolan
2458762acd Add auto generated cell ids 2022-09-21 13:02:33 +10:00
Sam Nolan
59e937ad7c Re-add noUnknown to yup schema for plots 2022-09-21 09:42:21 +09:30
Sam Nolan
483aaf73db Fixes multiple plots 2022-09-21 09:39:28 +09:30
Vyacheslav Matyukhin
4be410e33b
0.5.0-alpha.2 2022-09-21 03:41:12 +04:00
Vyacheslav Matyukhin
14070a589d
Merge pull request #1165 from quantified-uncertainty/typed-pointset-conversion
Typed pointset conversion
2022-09-21 03:21:22 +04:00
Vyacheslav Matyukhin
824749976e
tweaking names 2022-09-21 03:19:39 +04:00
Vyacheslav Matyukhin
59d38f7885
E.A.Floats.sort uses typed arrays 2022-09-21 03:17:25 +04:00
Vyacheslav Matyukhin
c9fc08672d
Merge pull request #1164 from quantified-uncertainty/no-fr-values
No frValues
2022-09-21 03:03:51 +04:00
Vyacheslav Matyukhin
25dce72f11
getExn -> get 2022-09-21 03:03:17 +04:00
Vyacheslav Matyukhin
d9f4171943
Merge pull request #1161 from quantified-uncertainty/sampleset-to-pointset-speedups
Sampleset to pointset speedups
2022-09-21 02:51:26 +04:00
Vyacheslav Matyukhin
a96f9ffa9a
another splitContinuousAndDiscrete test 2022-09-21 02:25:14 +04:00
Vyacheslav Matyukhin
13f352752e
review updates 2022-09-21 02:20:17 +04:00
Vyacheslav Matyukhin
5db63fbe9f
fastSort in toPointSet conversion 2022-09-21 01:42:54 +04:00
Vyacheslav Matyukhin
9f103f5cbe
3-arg fnDefinition 2022-09-20 21:08:42 +04:00
Vyacheslav Matyukhin
a4fd10e1fb
Merge branch 'overhaul' into no-fr-values 2022-09-20 20:54:36 +04:00
Vyacheslav Matyukhin
e07236c22d
fix scripts, support SAMPLE_COUNT 2022-09-20 20:54:26 +04:00
Vyacheslav Matyukhin
e079404f7c
Merge branch 'develop' into overhaul 2022-09-20 19:46:02 +04:00
Vyacheslav Matyukhin
4ed5ce0d47
WIP 2022-09-20 19:42:50 +04:00
dependabot[bot]
13f599be33
Merge pull request #1160 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/addon-essentials-6.5.12 2022-09-20 04:15:35 +00:00
dependabot[bot]
a247a05340
⬆️ Bump @storybook/addon-essentials from 6.5.10 to 6.5.12
Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/addons/essentials)

---
updated-dependencies:
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 04:06:31 +00:00
dependabot[bot]
80bbe2efb0
Merge pull request #1152 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/manager-webpack5-6.5.12 2022-09-20 04:01:24 +00:00
dependabot[bot]
795b432f86
⬆️ Bump @storybook/manager-webpack5 from 6.5.10 to 6.5.12
Bumps [@storybook/manager-webpack5](https://github.com/storybookjs/storybook/tree/HEAD/lib/core) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/lib/core)

---
updated-dependencies:
- dependency-name: "@storybook/manager-webpack5"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:52:37 +00:00
dependabot[bot]
7021286035
Merge pull request #1153 from quantified-uncertainty/dependabot/npm_and_yarn/ts-loader-9.4.0 2022-09-20 03:50:21 +00:00
dependabot[bot]
ce89041d68
Merge pull request #1158 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/addon-links-6.5.12 2022-09-20 03:44:37 +00:00
dependabot[bot]
bdffee0e13
Merge pull request #1151 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/addon-actions-6.5.12 2022-09-20 03:44:32 +00:00
dependabot[bot]
a30c63d547
Merge pull request #1155 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/react-6.5.12 2022-09-20 03:42:28 +00:00
dependabot[bot]
336c8b7d48
Merge pull request #1156 from quantified-uncertainty/dependabot/npm_and_yarn/headlessui/react-1.7.2 2022-09-20 03:39:30 +00:00
dependabot[bot]
ccc20e472e
⬆️ Bump ts-loader from 9.3.1 to 9.4.0
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.3.1 to 9.4.0.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.3.1...v9.4.0)

---
updated-dependencies:
- dependency-name: ts-loader
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:36:48 +00:00
dependabot[bot]
170b91742c
⬆️ Bump @storybook/addon-links from 6.5.10 to 6.5.12
Bumps [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/addons/links) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/addons/links)

---
updated-dependencies:
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:28:59 +00:00
dependabot[bot]
958c451589
⬆️ Bump @storybook/addon-actions from 6.5.10 to 6.5.12
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:28:33 +00:00
Quinn
0c12abe159
Merge pull request #1159 from quantified-uncertainty/dependabot/npm_and_yarn/vscode-uri-3.0.6
⬆️ Bump vscode-uri from 3.0.3 to 3.0.6
2022-09-19 23:28:21 -04:00
dependabot[bot]
388c2adcd4
⬆️ Bump @headlessui/react from 1.6.6 to 1.7.2
Bumps [@headlessui/react](https://github.com/tailwindlabs/headlessui/tree/HEAD/packages/@headlessui-react) from 1.6.6 to 1.7.2.
- [Release notes](https://github.com/tailwindlabs/headlessui/releases)
- [Changelog](https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/headlessui/commits/@headlessui/react@v1.7.2/packages/@headlessui-react)

---
updated-dependencies:
- dependency-name: "@headlessui/react"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:28:08 +00:00
dependabot[bot]
7d7cb74ad8
⬆️ Bump @storybook/react from 6.5.10 to 6.5.12
Bumps [@storybook/react](https://github.com/storybookjs/storybook/tree/HEAD/app/react) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/app/react)

---
updated-dependencies:
- dependency-name: "@storybook/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-20 03:27:57 +00:00
Quinn
8034de892e
Merge pull request #1157 from quantified-uncertainty/dependabot/npm_and_yarn/web-vitals-3.0.2
⬆️ Bump web-vitals from 3.0.1 to 3.0.2
2022-09-19 23:27:19 -04:00
Quinn
bb09fe9018
Merge pull request #1154 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.18
⬆️ Bump @types/node from 18.7.16 to 18.7.18
2022-09-19 23:25:01 -04:00
Quinn
7045fc6646
Merge pull request #1147 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.3.5
⬆️ Bump framer-motion from 7.3.2 to 7.3.5
2022-09-19 23:22:56 -04:00
Quinn
e01f12656a
Merge pull request #1146 from quantified-uncertainty/dependabot/npm_and_yarn/postcss-nesting-10.2.0
⬆️ Bump postcss-nesting from 10.1.10 to 10.2.0
2022-09-19 23:22:20 -04:00
Quinn
01031e9f97
Merge pull request #1145 from quantified-uncertainty/dependabot/npm_and_yarn/storybook/builder-webpack5-6.5.12
⬆️ Bump @storybook/builder-webpack5 from 6.5.10 to 6.5.12
2022-09-19 23:21:44 -04:00
Quinn
198dcc78c4
Merge pull request #1144 from quantified-uncertainty/dependabot/npm_and_yarn/floating-ui/react-dom-interactions-0.10.1
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.3 to 0.10.1
2022-09-19 23:21:15 -04:00
Vyacheslav Matyukhin
cdc49b378a
cleanup 2022-09-20 03:06:56 +04:00
Vyacheslav Matyukhin
5cf17f5dbf
cleanups 2022-09-20 02:47:29 +04:00
Vyacheslav Matyukhin
630128ae3f
bump website -> components dependency 2022-09-20 02:32:57 +04:00
Vyacheslav Matyukhin
4779ac2476
fix build errors 2022-09-20 02:25:28 +04:00
Vyacheslav Matyukhin
92483e66e0
yarn format 2022-09-20 02:19:55 +04:00
Vyacheslav Matyukhin
2392002172
0.5.0-alpha.1 versions 2022-09-20 02:07:47 +04:00
Vyacheslav Matyukhin
4a08718184
v0.5.0-alpha.0 2022-09-20 01:39:23 +04:00
Vyacheslav Matyukhin
fcbcfe3b66
Merge branch 'sampleset-to-pointset-speedups' into overhaul 2022-09-20 01:32:19 +04:00
Vyacheslav Matyukhin
6fc21ddda6
sampleset benchmark reports errors and accepts SAMPLE_COUNT 2022-09-20 01:26:19 +04:00
Vyacheslav Matyukhin
35671c5c51
format 2022-09-20 01:26:00 +04:00
Vyacheslav Matyukhin
ea71595e23
lower maxP in pointset benchmark 2022-09-20 00:59:46 +04:00
Vyacheslav Matyukhin
cb4e1199fc
reimplement splitContinuousAndDiscreteForMinWeight 2022-09-20 00:57:20 +04:00
Vyacheslav Matyukhin
8e396c44f9
refactor scripts 2022-09-20 00:57:20 +04:00
Vyacheslav Matyukhin
4f90dccdf1
refactor scripts 2022-09-20 00:55:32 +04:00
Vyacheslav Matyukhin
8e13caae84
fix merge artifacts 2022-09-19 23:20:37 +04:00
Vyacheslav Matyukhin
b24cfbc328
cleanups; ReducerInterface is no more 2022-09-19 23:10:09 +04:00
Vyacheslav Matyukhin
7a0c10d895
Merge branch 'develop' into overhaul 2022-09-19 22:07:25 +04:00
Vyacheslav Matyukhin
674213360c
trim lodash usage, remove unused module 2022-09-19 22:00:01 +04:00
Vyacheslav Matyukhin
f8b743feb5
tests; drop mathjs; new FR helpers; disable type tests 2022-09-19 21:46:37 +04:00
dependabot[bot]
a8e632f671
⬆️ Bump vscode-uri from 3.0.3 to 3.0.6
Bumps [vscode-uri](https://github.com/microsoft/vscode-uri) from 3.0.3 to 3.0.6.
- [Release notes](https://github.com/microsoft/vscode-uri/releases)
- [Commits](https://github.com/microsoft/vscode-uri/compare/v3.0.3...v3.0.6)

---
updated-dependencies:
- dependency-name: vscode-uri
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:27:32 +00:00
dependabot[bot]
72d6fa937d
⬆️ Bump web-vitals from 3.0.1 to 3.0.2
Bumps [web-vitals](https://github.com/GoogleChrome/web-vitals) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/GoogleChrome/web-vitals/releases)
- [Changelog](https://github.com/GoogleChrome/web-vitals/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleChrome/web-vitals/compare/v3.0.1...v3.0.2)

---
updated-dependencies:
- dependency-name: web-vitals
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:22:54 +00:00
dependabot[bot]
348ecc5eac
⬆️ Bump @types/node from 18.7.16 to 18.7.18
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.16 to 18.7.18.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:14:36 +00:00
dependabot[bot]
a15aa26439
Merge pull request #1143 from quantified-uncertainty/dependabot/npm_and_yarn/mathjs-11.2.1 2022-09-19 15:05:48 +00:00
dependabot[bot]
69cb8190f4
⬆️ Bump framer-motion from 7.3.2 to 7.3.5
Bumps [framer-motion](https://github.com/framer/motion) from 7.3.2 to 7.3.5.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.3.2...v7.3.5)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:04:25 +00:00
dependabot[bot]
3a255b397b
⬆️ Bump postcss-nesting from 10.1.10 to 10.2.0
Bumps [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/HEAD/plugins/postcss-nesting) from 10.1.10 to 10.2.0.
- [Release notes](https://github.com/csstools/postcss-plugins/releases)
- [Changelog](https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-nesting/CHANGELOG.md)
- [Commits](https://github.com/csstools/postcss-plugins/commits/HEAD/plugins/postcss-nesting)

---
updated-dependencies:
- dependency-name: postcss-nesting
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:02:50 +00:00
dependabot[bot]
2d4e529940
⬆️ Bump @storybook/builder-webpack5 from 6.5.10 to 6.5.12
Bumps [@storybook/builder-webpack5](https://github.com/storybookjs/storybook/tree/HEAD/lib/core) from 6.5.10 to 6.5.12.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.12/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.12/lib/core)

---
updated-dependencies:
- dependency-name: "@storybook/builder-webpack5"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 15:01:34 +00:00
dependabot[bot]
de4cac47cb
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.3 to 0.10.1
Bumps [@floating-ui/react-dom-interactions](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/react-dom-interactions) from 0.9.3 to 0.10.1.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/react-dom-interactions@0.10.1/packages/react-dom-interactions)

---
updated-dependencies:
- dependency-name: "@floating-ui/react-dom-interactions"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 14:59:38 +00:00
dependabot[bot]
d245971842
⬆️ Bump mathjs from 11.2.0 to 11.2.1
Bumps [mathjs](https://github.com/josdejong/mathjs) from 11.2.0 to 11.2.1.
- [Release notes](https://github.com/josdejong/mathjs/releases)
- [Changelog](https://github.com/josdejong/mathjs/blob/develop/HISTORY.md)
- [Commits](https://github.com/josdejong/mathjs/compare/v11.2.0...v11.2.1)

---
updated-dependencies:
- dependency-name: mathjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-19 14:57:13 +00:00
Vyacheslav Matyukhin
271303fb5f
fix more tests; FR improvements/refactorings 2022-09-19 15:00:38 +04:00
Sam Nolan
bd34b145f0 Remove re-export 2022-09-19 14:04:04 +10:00
Sam Nolan
c20af0edbd Format components 2022-09-19 14:00:49 +10:00
Sam Nolan
07731adc6f Add projects to components 2022-09-19 13:58:20 +10:00
Vyacheslav Matyukhin
2aaf6816f6
Merge pull request #1140 from quantified-uncertainty/scripts
benchmarking and testing scripts for squiggle-lang
2022-09-18 21:28:52 +04:00
Vyacheslav Matyukhin
a77bb36219
var name cleanups 2022-09-18 20:13:54 +04:00
Vyacheslav Matyukhin
66d9cb0ab1
.mjs for all scripts 2022-09-18 19:18:10 +04:00
Vyacheslav Matyukhin
a78797bb9c
benchmarking and testing scripts for squiggle-lang 2022-09-18 19:14:32 +04:00
Vyacheslav Matyukhin
6aa2280543
conver the rest of dispatch functions (Date, Duration) 2022-09-18 18:33:20 +04:00
Vyacheslav Matyukhin
bbc1bee313
fix more tests 2022-09-18 18:33:01 +04:00
Vyacheslav Matyukhin
fd4137b596
run-file.js improvements 2022-09-18 18:32:53 +04:00
Vyacheslav Matyukhin
43635bd39b
remove IEvArrayString, implement __result__, cleanups 2022-09-18 03:15:58 +04:00
Vyacheslav Matyukhin
065a7aeec0
immutable bindings; test fixes 2022-09-18 02:19:08 +04:00
Ozzie Gooen
7a220eae22
Merge pull request #1139 from quantified-uncertainty/components-build-fix
components v0.4.3 - fix build
2022-09-17 09:03:13 -07:00
Vyacheslav Matyukhin
21d84a5396
v0.4.3 2022-09-17 13:18:18 +04:00
Vyacheslav Matyukhin
89397d3584
ERecord->toString, fix warning 2022-09-17 00:41:58 +04:00
Vyacheslav Matyukhin
f62e90fa98
Reducer_Namespace; remove Module type; temporarily disable tests compilation 2022-09-17 00:30:44 +04:00
Vyacheslav Matyukhin
6463b52052
benchmark and other scripts 2022-09-15 15:17:19 +04:00
Ozzie Gooen
da8860ac41
Fixed typo in CODEOWNERS 2022-09-14 13:56:32 -07:00
Ozzie Gooen
36f7f00fc3
Merge pull request #1137 from quantified-uncertainty/develop
0.4.2 release
2022-09-14 13:44:31 -07:00
Vyacheslav Matyukhin
267023240f
Merge pull request #1136 from quantified-uncertainty/v0.4.2
V0.4.2
2022-09-15 00:25:18 +04:00
Vyacheslav Matyukhin
a6b24cb9e5
vscode ext 0.4.2 2022-09-15 00:24:46 +04:00
Vyacheslav Matyukhin
8d268ec433
v0.4.2 2022-09-15 00:11:39 +04:00
Vyacheslav Matyukhin
7b77dd09cf
v0.4.2 2022-09-15 00:07:16 +04:00
Vyacheslav Matyukhin
1e6a3d6495
Merge branch 'develop' into overhaul 2022-09-14 15:15:03 +04:00
Vyacheslav Matyukhin
884359597f
Merge branch 'develop' into overhaul 2022-09-14 14:49:44 +04:00
Vyacheslav Matyukhin
294acffb89
minor cleanups 2022-09-14 14:48:58 +04:00
Ozzie Gooen
cfb06afa2b
Merge pull request #1129 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.3.2
⬆️ Bump framer-motion from 7.2.1 to 7.3.2
2022-09-12 19:23:33 -07:00
Ozzie Gooen
9aa1d1fe93
Merge pull request #1125 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.16
⬆️ Bump @types/node from 18.7.15 to 18.7.16
2022-09-12 19:23:24 -07:00
Ozzie Gooen
47d00a350c
Merge pull request #1132 from quantified-uncertainty/no-pointset-sideeffects
fix sampleset -> pointset sorting sideeffects
2022-09-12 19:21:21 -07:00
Vyacheslav Matyukhin
1b714f0633
fix sampleset -> pointset sorting sideeffects 2022-09-13 03:55:59 +04:00
Vyacheslav Matyukhin
02c84983a4
more builtin functions 2022-09-13 03:51:49 +04:00
Vyacheslav Matyukhin
93b021dc52
Merge pull request #1130 from quantified-uncertainty/revert-1124-dependabot/npm_and_yarn/headlessui/react-1.7.0
Revert "⬆️ Bump @headlessui/react from 1.6.6 to 1.7.0"
2022-09-13 02:48:50 +04:00
Vyacheslav Matyukhin
be934af684
Revert "⬆️ Bump @headlessui/react from 1.6.6 to 1.7.0" 2022-09-13 01:07:32 +03:00
dependabot[bot]
e72ac8a44f
⬆️ Bump framer-motion from 7.2.1 to 7.3.2
Bumps [framer-motion](https://github.com/framer/motion) from 7.2.1 to 7.3.2.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.2.1...v7.3.2)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 16:02:32 +00:00
dependabot[bot]
b892a97e09
⬆️ Bump @types/node from 18.7.15 to 18.7.16
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.15 to 18.7.16.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 15:59:40 +00:00
Ozzie Gooen
4533d1a4fb
Merge pull request #1128 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-4.8.3
⬆️ Bump typescript from 4.8.2 to 4.8.3
2022-09-12 08:55:43 -07:00
Ozzie Gooen
4beb1e5378
Merge pull request #1127 from quantified-uncertainty/dependabot/npm_and_yarn/types/lodash-4.14.185
⬆️ Bump @types/lodash from 4.14.184 to 4.14.185
2022-09-12 08:55:28 -07:00
Ozzie Gooen
95d0884ce6
Merge pull request #1126 from quantified-uncertainty/dependabot/npm_and_yarn/hookform/resolvers-2.9.8
⬆️ Bump @hookform/resolvers from 2.9.7 to 2.9.8
2022-09-12 08:55:20 -07:00
Ozzie Gooen
a47107e2a4
Merge pull request #1124 from quantified-uncertainty/dependabot/npm_and_yarn/headlessui/react-1.7.0
⬆️ Bump @headlessui/react from 1.6.6 to 1.7.0
2022-09-12 08:55:10 -07:00
Ozzie Gooen
4c0b5e5e97
Merge pull request #1123 from quantified-uncertainty/dependabot/npm_and_yarn/webpack-dev-server-4.11.0
⬆️ Bump webpack-dev-server from 4.10.1 to 4.11.0
2022-09-12 08:54:57 -07:00
Ozzie Gooen
0c9c2c5c50
Merge pull request #1122 from quantified-uncertainty/dependabot/npm_and_yarn/fast-check-3.1.3
⬆️ Bump fast-check from 3.1.2 to 3.1.3
2022-09-12 08:54:46 -07:00
Ozzie Gooen
9cd2b661db
Merge pull request #1121 from quantified-uncertainty/dependabot/npm_and_yarn/mathjs-11.2.0
⬆️ Bump mathjs from 11.1.0 to 11.2.0
2022-09-12 08:54:37 -07:00
Ozzie Gooen
1132b54be6
Merge pull request #1120 from quantified-uncertainty/dependabot/npm_and_yarn/react-hook-form-7.35.0
⬆️ Bump react-hook-form from 7.34.2 to 7.35.0
2022-09-12 08:54:28 -07:00
dependabot[bot]
60eba96172
⬆️ Bump typescript from 4.8.2 to 4.8.3
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.8.2 to 4.8.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.8.2...v4.8.3)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:39:54 +00:00
dependabot[bot]
f41447c263
⬆️ Bump @types/lodash from 4.14.184 to 4.14.185
Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.14.184 to 4.14.185.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash)

---
updated-dependencies:
- dependency-name: "@types/lodash"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:38:30 +00:00
dependabot[bot]
ae130bbef4
⬆️ Bump @hookform/resolvers from 2.9.7 to 2.9.8
Bumps [@hookform/resolvers](https://github.com/react-hook-form/resolvers) from 2.9.7 to 2.9.8.
- [Release notes](https://github.com/react-hook-form/resolvers/releases)
- [Commits](https://github.com/react-hook-form/resolvers/compare/v2.9.7...v2.9.8)

---
updated-dependencies:
- dependency-name: "@hookform/resolvers"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:37:48 +00:00
dependabot[bot]
159f8721d8
⬆️ Bump @headlessui/react from 1.6.6 to 1.7.0
Bumps [@headlessui/react](https://github.com/tailwindlabs/headlessui/tree/HEAD/packages/@headlessui-react) from 1.6.6 to 1.7.0.
- [Release notes](https://github.com/tailwindlabs/headlessui/releases)
- [Changelog](https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/CHANGELOG.md)
- [Commits](https://github.com/tailwindlabs/headlessui/commits/@headlessui/react@v1.7.0/packages/@headlessui-react)

---
updated-dependencies:
- dependency-name: "@headlessui/react"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:35:58 +00:00
dependabot[bot]
901ee9f2fd
⬆️ Bump webpack-dev-server from 4.10.1 to 4.11.0
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.10.1 to 4.11.0.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.10.1...v4.11.0)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:34:46 +00:00
dependabot[bot]
20654c4f08
⬆️ Bump fast-check from 3.1.2 to 3.1.3
Bumps [fast-check](https://github.com/dubzzz/fast-check/tree/HEAD/packages/fast-check) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/dubzzz/fast-check/releases)
- [Changelog](https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/CHANGELOG.md)
- [Commits](https://github.com/dubzzz/fast-check/commits/v3.1.3/packages/fast-check)

---
updated-dependencies:
- dependency-name: fast-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:32:53 +00:00
dependabot[bot]
565bcf8331
⬆️ Bump mathjs from 11.1.0 to 11.2.0
Bumps [mathjs](https://github.com/josdejong/mathjs) from 11.1.0 to 11.2.0.
- [Release notes](https://github.com/josdejong/mathjs/releases)
- [Changelog](https://github.com/josdejong/mathjs/blob/develop/HISTORY.md)
- [Commits](https://github.com/josdejong/mathjs/compare/v11.1.0...v11.2.0)

---
updated-dependencies:
- dependency-name: mathjs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:32:19 +00:00
dependabot[bot]
28310168cb
⬆️ Bump react-hook-form from 7.34.2 to 7.35.0
Bumps [react-hook-form](https://github.com/react-hook-form/react-hook-form) from 7.34.2 to 7.35.0.
- [Release notes](https://github.com/react-hook-form/react-hook-form/releases)
- [Changelog](https://github.com/react-hook-form/react-hook-form/blob/master/CHANGELOG.md)
- [Commits](https://github.com/react-hook-form/react-hook-form/compare/v7.34.2...v7.35.0)

---
updated-dependencies:
- dependency-name: react-hook-form
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 14:31:47 +00:00
Vyacheslav Matyukhin
36127d8947
cleanup benchmark script 2022-09-12 14:44:35 +04:00
Vyacheslav Matyukhin
97ff56b46a
link dependencies 2022-09-12 13:42:39 +04:00
Vyacheslav Matyukhin
757d458ecf
more FR 2022-09-12 13:33:41 +04:00
dependabot[bot]
d02aa61b87
Merge pull request #1080 from quantified-uncertainty/dependabot/npm_and_yarn/postcss-import-15.0.0 2022-09-12 07:23:58 +00:00
dependabot[bot]
e571700944
⬆️ Bump postcss-import from 14.1.0 to 15.0.0
Bumps [postcss-import](https://github.com/postcss/postcss-import) from 14.1.0 to 15.0.0.
- [Release notes](https://github.com/postcss/postcss-import/releases)
- [Changelog](https://github.com/postcss/postcss-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss-import/compare/14.1.0...15.0.0)

---
updated-dependencies:
- dependency-name: postcss-import
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 07:14:42 +00:00
Quinn
d57fe27a0d
Merge pull request #1118 from quantified-uncertainty/revert-nix
restore old ci
2022-09-12 02:07:51 -04:00
Quinn Dougherty
7beff3f834 uncommented out most of the jobs 2022-09-12 13:50:21 +08:00
Quinn Dougherty
3677b9582e Merge remote-tracking branch 'origin/develop' into fix-nixbuild 2022-09-12 11:53:46 +08:00
Quinn Dougherty
b49e8c43f0 added another file to un.gitignore 2022-09-12 11:53:29 +08:00
Ozzie Gooen
8b4ea5079a
Added @berekuk as codeowner. 2022-09-11 19:28:26 -07:00
Vyacheslav Matyukhin
681a1b42c6
delete unused 2022-09-12 03:21:49 +04:00
Vyacheslav Matyukhin
6dc1cea045
more WIP 2022-09-12 03:07:34 +04:00
Ozzie Gooen
4408ed642d
Merge pull request #1117 from quantified-uncertainty/e-modules-ocaml
E modules OCaml style
2022-09-11 13:52:24 -07:00
Ozzie Gooen
f7f3e449d1
Delete E copy.resxxx 2022-09-11 13:47:58 -07:00
Ozzie Gooen
d55c72f39e
Merge pull request #1115 from quantified-uncertainty/map-efficiency
Slightly faster map and filter implementations
2022-09-11 13:44:56 -07:00
Vyacheslav Matyukhin
fea89abff9
more WIP 2022-09-11 23:56:07 +04:00
Umur Ozkul
5de73f171c E modules OCaml style
Huge E decomposed in to files
2022-09-11 21:52:25 +02:00
Vyacheslav Matyukhin
f2dccd4f1e
still WIP, FR works 2022-09-11 20:57:28 +04:00
Vyacheslav Matyukhin
7a29be3845
WIP (basic functionality, stdlib not converted yet) 2022-09-11 19:22:07 +04:00
Ozzie Gooen
5772c458a8
Merge pull request #1047 from quantified-uncertainty/exceptional-reducer
Exceptional reducer (~20% speedup)
2022-09-11 08:09:51 -07:00
Umur Ozkul
c59404e65f Merge branch 'exceptional-reducer' into map-efficiency 2022-09-11 17:01:39 +02:00
Umur Ozkul
4346ba992f Merge branch 'develop' into exceptional-reducer
packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_IncludeParser.js
2022-09-11 17:00:18 +02:00
Umur Ozkul
4fc10823fe Merge branch 'exceptional-reducer' into map-efficiency 2022-09-11 15:31:40 +02:00
Vyacheslav Matyukhin
fe56e81710
WIP 2022-09-10 21:01:04 +04:00
Vyacheslav Matyukhin
1187c0330a
faster filter 2022-09-09 17:04:32 +04:00
Vyacheslav Matyukhin
4d1f76f80e
slightly faster map implementation
see this comment: https://github.com/quantified-uncertainty/squiggle/pull/1047#issuecomment-1241805927
2022-09-09 14:39:42 +04:00
Quinn Dougherty
4dc7619e5a hotfix: manual versions in .release-please-manifest.json 2022-09-09 15:28:29 +08:00
Quinn Dougherty
3c0255cfb9 hotfix: lint docs 2022-09-09 15:26:20 +08:00
Umur Ozkul
5d17301016 remove raise 2022-09-09 01:14:42 +02:00
Ozzie Gooen
45323b0e08
Merge pull request #1008 from ideopunk/feature/distribution_tweaks
Distribution component tweaks
2022-09-08 15:49:58 -07:00
Umur Ozkul
1c98aaa3e2 value vs result conversion functions 2022-09-09 00:43:21 +02:00
Conor Barnes
2736fb9a17 delete conflicting file 2022-09-08 16:31:02 -03:00
Ozzie Gooen
b5f5cca0dc
Merge pull request #1110 from quantified-uncertainty/remove-generated-include-parser
remove generated ReducerProject_IncludeParser.js from repo
2022-09-08 10:36:41 -07:00
Vyacheslav Matyukhin
d3788fb411
remove generated ReducerProject_IncludeParser.js from repo 2022-09-08 16:27:32 +04:00
Vyacheslav Matyukhin
ecc82ba8f7
reformat for lint 2022-09-07 23:04:07 +04:00
Vyacheslav Matyukhin
06ec2caae0
remove unused code 2022-09-07 22:50:24 +04:00
Vyacheslav Matyukhin
c0ccdbc1e9
experimental: replace result with exceptions in reducer 2022-09-07 22:45:19 +04:00
Ozzie Gooen
45dd199925
Merge pull request #1102 from quantified-uncertainty/develop
V0.4.1
2022-09-07 09:44:37 -07:00
Conor Barnes
5b0d7a898f remove dead comments and simplify sample inclusion 2022-09-07 11:01:18 -03:00
Conor Barnes
0c614a3fcf samples in own shape 2022-09-07 09:18:01 -03:00
Ozzie Gooen
7d6ffecc4a Merge branch 'develop' of github.com:quantified-uncertainty/squiggle into develop
* 'develop' of github.com:quantified-uncertainty/squiggle:
  fix: docs bug
  0.4.1 version of all packages
  0.0.0 version for website package
  bump components dependency for website
  bump and sync versions for 0.4.0-alpha.4 release
2022-09-06 15:03:36 -07:00
Ozzie Gooen
7d8a7e19d5 Ran yarn format 2022-09-06 15:03:24 -07:00
Ozzie Gooen
046f4f4f47
Merge pull request #1101 from quantified-uncertainty/0.4-release
0.4.1 release
2022-09-06 14:50:07 -07:00
ad32921ed0 fix: docs bug 2022-09-06 23:44:34 +02:00
Vyacheslav Matyukhin
6f10b276e9
0.4.1 version of all packages 2022-09-07 01:24:08 +04:00
Vyacheslav Matyukhin
4a75a97cb4
0.0.0 version for website package
we don't have to set it since we never publish the website to npm, and
bumping the version does nothing useful

0.0.0 is from here: https://github.com/yarnpkg/yarn/issues/5936#issuecomment-395912169

see that issue for details on how this was fixed with yarn@2, but we're
still on yarn@1.22
2022-09-07 00:39:19 +04:00
Vyacheslav Matyukhin
36cd9271f6
bump components dependency for website 2022-09-07 00:24:52 +04:00
Vyacheslav Matyukhin
2a8e5866cb
bump and sync versions for 0.4.0-alpha.4 release 2022-09-07 00:18:56 +04:00
Ozzie Gooen
9a67b16eee
Merge pull request #1069 from quantified-uncertainty/more-functions
[work in progress] Add more functions
2022-09-06 13:03:54 -07:00
Ozzie Gooen
00a22b456d Removed now-not-needed text 2022-09-06 13:03:39 -07:00
458c4f65b1 tweak: remove vscode config 2022-09-06 21:49:26 +02:00
Vyacheslav Matyukhin
00a0005e56
Merge branch 'develop' into fixes-for-ideopunk
Also some SqDistribution fixes.
2022-09-06 23:35:37 +04:00
fad1b51630 feat: simplify Danger functions
yarn.lock also changed because of the previous commmit
2022-09-06 21:16:29 +02:00
b7a186f8ac fix: components warning
Solution per
<https://tailwindcss.com/docs/using-with-preprocessors#nesting>
was enabled, but the necessary dev dependencies not enabled,
which caused problems
2022-09-06 21:07:49 +02:00
4917c2e0e2 Merge branch 'develop' of github.com:quantified-uncertainty/squiggle into more-functions 2022-09-06 21:00:17 +02:00
Ozzie Gooen
ceb92ccfc6
Merge pull request #1097 from quantified-uncertainty/reducer-constructArray
fixes #558 fixes #1038 construct an array of lambda functions
2022-09-06 11:37:07 -07:00
Umur Ozkul
0131498aca fixes #558 fixes #1038 2022-09-06 20:15:57 +02:00
Conor Barnes
e0cd95fe5c remove unnecessary mapping of sample array to array of objects 2022-09-06 14:52:57 -03:00
Ozzie Gooen
84be552782
Merge pull request #1009 from quantified-uncertainty/epic-reducer-project
0.4.0 - Epic reducer project
2022-09-06 10:42:15 -07:00
Conor Barnes
6c87a9e712 rename to xAxisType 2022-09-06 14:30:52 -03:00
Conor Barnes
3ea747fae4 simplify code by not mapping x property to dateTime property 2022-09-06 14:27:01 -03:00
3b45355ce7 feat: Add documentation 2022-09-06 15:43:58 +02:00
cf75152608 tweak: more cleanup 2022-09-06 15:17:20 +02:00
162f158dbc tweak: Use firstErrorOrOpen instead of hack 2022-09-06 14:54:59 +02:00
fc2d647b62 tweak: Add error checking to dmr calculation 2022-09-06 14:49:58 +02:00
60e42cf1e8 cleanup: More Dangers cleanup
and formatting
2022-09-06 14:25:03 +02:00
ae71bb8ec5 tweak: Move cast function to registry helpers file and rename 2022-09-06 14:05:08 +02:00
4903319073 format 2022-09-06 13:59:21 +02:00
edce22050a cleanup: Move integrals to its own module 2022-09-06 13:59:03 +02:00
8ddd1a166a tweak: Move combinatorics functions to its own module 2022-09-06 13:55:28 +02:00
697e3ba852 cleanup: Delete large amounts of dead code from Danger.
But keep pointer to commit
2022-09-06 13:44:55 +02:00
5ce0a6979d tweak: Also use helpers in Number lib
Avoids code duplication
2022-09-06 13:39:02 +02:00
d8d68445b6 git add: Use helpers in Danger lib 2022-09-06 13:37:36 +02:00
b21d5d09a8 tweak: Add number function helpers 2022-09-06 13:36:43 +02:00
Ozzie Gooen
6c3f719e74
Merge pull request #1094 from quantified-uncertainty/danger-adjustments
Danger adjustments
2022-09-05 20:21:37 -07:00
Ozzie Gooen
38447f1633 Merged with epic-reducer-project 2022-09-05 20:19:35 -07:00
Ozzie Gooen
c5928129d7 Minor cleanup to danger files 2022-09-05 20:16:41 -07:00
Ozzie Gooen
ddfc617776
Merge pull request #1074 from Nathanpmyoung/patch-3
Added detail to explanation of quantile function
2022-09-05 14:37:12 -07:00
Ozzie Gooen
4fbbd39638
Merge branch 'develop' into patch-3 2022-09-05 14:26:54 -07:00
Ozzie Gooen
c44d75695d
Merge pull request #1088 from quantified-uncertainty/function-charts-without-pointset-conversion
don't convert dists to pointset when rendering lambdas
2022-09-05 13:59:58 -07:00
Ozzie Gooen
b833da4ac2
Merge pull request #1084 from quantified-uncertainty/dependabot/npm_and_yarn/docusaurus/preset-classic-2.1.0
⬆️ Bump @docusaurus/preset-classic from 2.0.1 to 2.1.0
2022-09-05 13:58:17 -07:00
cae8f8cb65 tweak: tested examples in playground 2022-09-05 22:14:26 +02:00
bfc3b39b2b tweak: format 2022-09-05 22:08:20 +02:00
e1760dab2d tweak: Cleanup 2022-09-05 22:08:00 +02:00
f76de31d26 faustian bargain: create 6 different Danger.dmr functions
So ugly that it's almost beautiful. Except it's not
2022-09-05 21:59:53 +02:00
c183dbd24b tweak: Continue building skeleton for Danger dmr 2022-09-05 21:40:20 +02:00
70d9a5c9f3 tweak: save intermediary state 2022-09-05 20:52:23 +02:00
dependabot[bot]
db3326ac34
⬆️ Bump @docusaurus/preset-classic from 2.0.1 to 2.1.0
Bumps [@docusaurus/preset-classic](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-preset-classic) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v2.1.0/packages/docusaurus-preset-classic)

---
updated-dependencies:
- dependency-name: "@docusaurus/preset-classic"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 17:58:50 +00:00
Ozzie Gooen
edc7173fb6
Merge pull request #1076 from quantified-uncertainty/dependabot/npm_and_yarn/web-vitals-3.0.1
⬆️ Bump web-vitals from 3.0.0 to 3.0.1
2022-09-05 10:56:53 -07:00
Ozzie Gooen
d033db1155
Merge pull request #1077 from quantified-uncertainty/dependabot/npm_and_yarn/types/glob-8.0.0
⬆️ Bump @types/glob from 7.2.0 to 8.0.0
2022-09-05 10:56:46 -07:00
Ozzie Gooen
deec676d4e
Merge pull request #1078 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.15
⬆️ Bump @types/node from 18.7.14 to 18.7.15
2022-09-05 10:56:36 -07:00
Ozzie Gooen
02033b8dc1
Merge pull request #1079 from quantified-uncertainty/dependabot/npm_and_yarn/types/vscode-1.71.0
⬆️ Bump @types/vscode from 1.70.0 to 1.71.0
2022-09-05 10:56:29 -07:00
Ozzie Gooen
2b86fb7723
Merge pull request #1083 from quantified-uncertainty/dependabot/npm_and_yarn/testing-library/react-13.4.0
⬆️ Bump @testing-library/react from 13.3.0 to 13.4.0
2022-09-05 10:56:20 -07:00
Ozzie Gooen
8db0562f75
Merge pull request #1082 from quantified-uncertainty/dependabot/npm_and_yarn/vscode-languageserver-textdocument-1.0.7
⬆️ Bump vscode-languageserver-textdocument from 1.0.5 to 1.0.7
2022-09-05 10:56:11 -07:00
Ozzie Gooen
660aaf24ab
Merge pull request #1081 from quantified-uncertainty/dependabot/npm_and_yarn/docusaurus/core-2.1.0
⬆️ Bump @docusaurus/core from 2.0.1 to 2.1.0
2022-09-05 10:55:44 -07:00
Vyacheslav Matyukhin
74e54c6e91
Merge branch 'epic-reducer-project' into function-charts-without-pointset-conversion 2022-09-05 21:41:01 +04:00
Vyacheslav Matyukhin
3c879432f2
Merge branch 'develop' into epic-reducer-project 2022-09-05 21:40:45 +04:00
Vyacheslav Matyukhin
2942067849
don't convert dists to pointset when rendering lambdas 2022-09-05 21:39:03 +04:00
dependabot[bot]
5607d65599
⬆️ Bump @testing-library/react from 13.3.0 to 13.4.0
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 13.3.0 to 13.4.0.
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-testing-library/compare/v13.3.0...v13.4.0)

---
updated-dependencies:
- dependency-name: "@testing-library/react"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:58:04 +00:00
dependabot[bot]
86e41e0fe2
⬆️ Bump @types/node from 18.7.14 to 18.7.15
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.14 to 18.7.15.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:55:19 +00:00
dependabot[bot]
f76a5f5ce4
⬆️ Bump web-vitals from 3.0.0 to 3.0.1
Bumps [web-vitals](https://github.com/GoogleChrome/web-vitals) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/GoogleChrome/web-vitals/releases)
- [Changelog](https://github.com/GoogleChrome/web-vitals/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleChrome/web-vitals/compare/v3.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: web-vitals
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:52:55 +00:00
dependabot[bot]
de06586784
⬆️ Bump @types/glob from 7.2.0 to 8.0.0
Bumps [@types/glob](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/glob) from 7.2.0 to 8.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/glob)

---
updated-dependencies:
- dependency-name: "@types/glob"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:46:36 +00:00
dependabot[bot]
41e5f300ef
⬆️ Bump vscode-languageserver-textdocument from 1.0.5 to 1.0.7
Bumps [vscode-languageserver-textdocument](https://github.com/Microsoft/vscode-languageserver-node/tree/HEAD/textDocument) from 1.0.5 to 1.0.7.
- [Release notes](https://github.com/Microsoft/vscode-languageserver-node/releases)
- [Commits](https://github.com/Microsoft/vscode-languageserver-node/commits/release/textdocument/1.0.7/textDocument)

---
updated-dependencies:
- dependency-name: vscode-languageserver-textdocument
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:46:15 +00:00
dependabot[bot]
417df076d0
⬆️ Bump @types/vscode from 1.70.0 to 1.71.0
Bumps [@types/vscode](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/vscode) from 1.70.0 to 1.71.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/vscode)

---
updated-dependencies:
- dependency-name: "@types/vscode"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:45:33 +00:00
dependabot[bot]
3084c557fd
⬆️ Bump @docusaurus/core from 2.0.1 to 2.1.0
Bumps [@docusaurus/core](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v2.1.0/packages/docusaurus)

---
updated-dependencies:
- dependency-name: "@docusaurus/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:35:54 +00:00
8bdfa03799 feat: In Danger, add dmr for many functions
Still to be tested
2022-09-05 17:05:25 +02:00
Ozzie Gooen
7f8f6f4fd6
Merge pull request #1086 from quantified-uncertainty/dependabot/npm_and_yarn/types/react-18.0.18
⬆️ Bump @types/react from 18.0.17 to 18.0.18
2022-09-05 07:44:56 -07:00
2f33559e77 tweak: in Danger namespace change function name
to make clear that it takes only two inputs,
while I build the many-inputs version
2022-09-05 16:40:17 +02:00
Ozzie Gooen
6a38d6c0bf
Merge pull request #1073 from Nathanpmyoung/patch-2
Correct spelling error in "quantile section"
2022-09-05 07:31:06 -07:00
9551aae634 tweak: format 2022-09-05 16:08:06 +02:00
8f8ca02730 tweak: get possibly working dmr function 2022-09-05 15:58:08 +02:00
b13da70c38 tweak: Build Danger.dmr skeleton more 2022-09-05 15:51:55 +02:00
dependabot[bot]
d71e6cf7d5
⬆️ Bump @types/react from 18.0.17 to 18.0.18
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.0.17 to 18.0.18.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 13:44:29 +00:00
be4e1b1a85 tweak: In Danger namespace, build dmr function further
dmr = diminishing marginal returns
2022-09-05 15:27:59 +02:00
Nathanpmyoung
54fe141a7d
Added detail to explanation of quantile function
I didn't understand it so I thought I'd make it easier for the next person.
2022-09-05 13:26:36 +01:00
Nathanpmyoung
6ea94b0c8f
Correct spelling error 2022-09-05 13:18:01 +01:00
fe3075b3bf tweak: In Danger namespace, further diminishingMarginalReturnsSkeleton 2022-09-05 14:12:34 +02:00
aa3173f85b tweak: Add skeleton for calculating dimishing returns allocation 2022-09-05 14:00:14 +02:00
f370c44771 tiny tweak: better example 2022-09-05 13:09:28 +02:00
c0713b16c2 tweak: Add better error messages for common use case
I.e., the case of integrating a function which
doesn't return a number but a distribution
2022-09-05 13:03:56 +02:00
2b414191ac tweak: Numerate integration errors. 2022-09-05 12:49:47 +02:00
a45e38d75d feat: Cleanup of Danger namespace 2022-09-05 12:38:15 +02:00
6d75af61c3 fix: formatting 2022-09-05 12:16:19 +02:00
27ca86e729 feat: Worked out kinks of the integral! 2022-09-05 12:11:42 +02:00
fd7720b045 fix: formatting 2022-09-05 09:39:55 +02:00
2fa97c20f7 fix: Off by one error due to Belt.Array.makeBy 2022-09-05 09:37:48 +02:00
6c04f9bff1 fix: change expected output type of integrals 2022-09-05 09:10:42 +02:00
e73ffaa10a feat: Added a slightly better integral function
Slightly better because the handling of bounds is better.
Previously we were integrating at min, min + interval,
min + i*interval, ...
which meanst that sometimes we weren't integrating at
max.

Also a minimal amount of cleanup
2022-09-05 09:08:53 +02:00
abad453523 fix: no small integration error 2022-09-05 08:41:33 +02:00
Quinn
65e083eda2
Merge pull request #1070 from quantified-uncertainty/dependabot-labels
explicit and minimal dependabot labels config
2022-09-04 23:09:25 -04:00
244f3ea8d9 feat: Note that this isn't tested yet. 2022-09-04 22:48:29 +02:00
ecf5249b5c feat: And integration function to Danger namespace
Note that I haven't tested this yet.
2022-09-04 22:45:55 +02:00
Umur Ozkul
3794909efc format js 2022-09-04 21:53:02 +02:00
Umur Ozkul
b73924135f format rescritp 2022-09-04 21:52:48 +02:00
Umur Ozkul
247e101324 PR comment 2022-09-04 21:24:53 +02:00
Umur Ozkul
044ed0bea3 qualify IEvVoid 2022-09-04 21:19:27 +02:00
943e63b379 link: run pretty 2022-09-04 20:26:57 +02:00
Vyacheslav Matyukhin
af079d3cb7
explicit and minimal dependabot lables config 2022-09-04 22:17:05 +04:00
b292a3e6fd tweak: Add to dos to continue tomorrow 2022-09-04 20:07:10 +02:00
f82c00a6ed tweak: Work out how to apply a function to an
arbitrary value in the Danger domain
2022-09-04 19:29:22 +02:00
b45ab3dba2 feat: In Danger namespace, work out how to apply function 2022-09-04 19:22:12 +02:00
b57233096d tweak: Revert back to working state in Danger namespace 2022-09-04 19:04:13 +02:00
dc34e7c0b8 feat: Danger namespace function tweaking 2022-09-04 18:58:19 +02:00
85fe4d16a2 tweak: Intermediary step while figuring out
function application
2022-09-04 18:53:57 +02:00
Ozzie Gooen
641b51f4d5
Merge pull request #1068 from quantified-uncertainty/clean-components-builds
Clean components builds
2022-09-04 09:38:28 -07:00
803231d620 feat: add a few more simple functions to Danger namespace 2022-09-04 17:12:18 +02:00
3106a10b90 tweak: Move new functions to the "Danger" namespace 2022-09-04 15:31:18 +02:00
19ddd4eb3f tweak: Add TwoNumbersToNumber wrapper to function registry. 2022-09-04 15:09:09 +02:00
Vyacheslav Matyukhin
cebd8118b0
clean dist/src on components builds 2022-09-04 16:30:03 +04:00
Ozzie Gooen
58a44fe437
Merge pull request #1064 from quantified-uncertainty/v0.4.0-alpha-versioning
Version packages for 0.4.0-alpha
2022-09-03 18:37:16 -07:00
Ozzie Gooen
520b361f2c Alpha-versioning 2022-09-02 19:53:22 -07:00
Ozzie Gooen
7a60f736f1
Merge branch 'develop' into epic-reducer-project 2022-09-01 13:45:20 -07:00
Ozzie Gooen
4ecb692e80
Merge pull request #1057 from quantified-uncertainty/develop
V0.3.1
2022-09-01 11:23:27 -07:00
Ozzie Gooen
462f1c9649
Merge pull request #1056 from quantified-uncertainty/to-0.3.1
0.3.0 -> 0.3.1
2022-09-01 11:00:52 -07:00
Ozzie Gooen
e522eb4c5f 0.3.0 -> 0.3.1 2022-09-01 11:00:23 -07:00
Vyacheslav Matyukhin
7e3fa1d65a
Merge branch 'develop' into epic-reducer-project 2022-09-01 21:15:18 +04:00
Ozzie Gooen
a97d1bae6d
Merge pull request #1050 from quantified-uncertainty/SampleSet.max-min
Added SampleSet.min and Sampleset.max
2022-09-01 09:07:02 -07:00
Vyacheslav Matyukhin
4d2fefad69
fix typo in test name 2022-09-01 19:26:57 +04:00
Vyacheslav Matyukhin
4f10cabdd3
Merge pull request #1053 from quantified-uncertainty/lambdas-in-result
support for __result__ in web components and SqLambda
2022-09-01 19:24:34 +04:00
Vyacheslav Matyukhin
130af680f6
Merge pull request #1052 from quantified-uncertainty/reducer-project-imports
Reducer project imports
2022-09-01 19:12:37 +04:00
Vyacheslav Matyukhin
fc3a7c6cf9
support for __result__ in web components and SqLambda 2022-09-01 19:11:49 +04:00
Vyacheslav Matyukhin
e2abc53200
improve code generation for jsImports 2022-09-01 18:55:15 +04:00
Vyacheslav Matyukhin
64ed32a17c
support jsImports 2022-09-01 18:44:13 +04:00
Vyacheslav Matyukhin
8842f7b25e
delete getDependents and getDependencies methods from TS API 2022-09-01 18:15:36 +04:00
Vyacheslav Matyukhin
d76c2f8ac7
new jsImports (WIP) 2022-09-01 18:14:12 +04:00
Vyacheslav Matyukhin
407984344b
test for project with multiple independent sources 2022-09-01 18:13:11 +04:00
Umur Ozkul
f21f635bf0
Merge pull request #1051 from quantified-uncertainty/topsort-improvement
Topological sort improvement
2022-09-01 16:08:47 +02:00
Vyacheslav Matyukhin
dd3a8ab736
getRunOrderFor runs topological sort from current id 2022-09-01 17:57:04 +04:00
Umur Ozkul
ec93a82110 format 2022-09-01 14:53:01 +02:00
Umur Ozkul
1fe0aefd6b Merge branch 'epic-reducer-project' of github.com:quantified-uncertainty/squiggle into epic-reducer-project 2022-09-01 14:52:14 +02:00
Umur Ozkul
7eef1d30f3 __result__ variable in bindings 2022-09-01 14:51:20 +02:00
Umur Ozkul
82a4e52384 include and "include as" 2022-09-01 14:32:24 +02:00
Vyacheslav Matyukhin
b3d5a98518
Merge pull request #1011 from quantified-uncertainty/reducer-project-ts
ReducerProject - TS side
2022-09-01 15:08:54 +04:00
Vyacheslav Matyukhin
59ed741f33
show either result or bindings in viewer 2022-09-01 15:02:32 +04:00
Vyacheslav Matyukhin
4a3c982c57
remove SquiggleEditorWithImportedBindings 2022-09-01 14:45:47 +04:00
Vyacheslav Matyukhin
48fb634140
fix more tests for new TS classes 2022-09-01 14:36:27 +04:00
Vyacheslav Matyukhin
eda1a45fda
reenable environment in useSquiggle 2022-09-01 13:32:11 +04:00
Quinn
e6d543daef
Merge pull request #1002 from quantified-uncertainty/sampleset-mixture
Sampleset mixture
2022-09-01 03:00:17 -04:00
Quinn Dougherty
38d0ea79e4 yarn format:all compels me 2022-09-01 14:22:32 +08:00
Quinn Dougherty
57dca26d2b fix the resolve to @stdlib/buffer 2022-09-01 14:08:14 +08:00
Ozzie Gooen
e582fc5be3 library1 -> libraryBase 2022-08-31 22:15:13 -07:00
Ozzie Gooen
96815b6ee5 Really simple tests for SampleSet.min and max 2022-08-31 22:14:41 -07:00
Quinn Dougherty
ab9a83bcf7 I think we're done here? 2022-09-01 13:07:13 +08:00
Quinn Dougherty
ab5b54413b it string in tests 2022-09-01 12:54:04 +08:00
Quinn Dougherty
9366ce61f3 yarn format compels me 2022-09-01 12:48:20 +08:00
Quinn Dougherty
989fa9644a rm |> in favor of -> 2022-09-01 12:48:07 +08:00
Ozzie Gooen
255541a679 Added SampleSet.min and Sampleset.max 2022-08-31 21:43:36 -07:00
Quinn Dougherty
729fc2c59d Merge remote-tracking branch 'origin/develop' into sampleset-mixture 2022-09-01 12:39:55 +08:00
Quinn Dougherty
152432b6d6 hotfix: switch release-please to master (3) 2022-09-01 12:17:42 +08:00
Quinn Dougherty
2209fd179e hotfix: switch release-please to master (2) 2022-09-01 12:14:23 +08:00
Quinn Dougherty
b6a2eac8fc hotfix: switch release-please to master 2022-09-01 12:12:34 +08:00
Ozzie Gooen
d50c9ca930
Merge pull request #1049 from quantified-uncertainty/playground-show-summary-by-default
Playground should show stat summary by default
2022-08-31 20:54:27 -07:00
Ozzie Gooen
64539bc121 Playground should show stat summary by default 2022-08-31 20:53:48 -07:00
Quinn Dougherty
3153b9620a fix: test trigger release-please, for fun 2022-09-01 11:37:24 +08:00
Ozzie Gooen
5e9bf521fa
Merge pull request #1042 from quantified-uncertainty/getByWithFn
Changed getByWithFn to not need two function calls
2022-08-31 20:10:30 -07:00
Ozzie Gooen
0fa34b09e4
Merge pull request #995 from quantified-uncertainty/sampleSet-truncate
Added truncate for SampleSet distribution
2022-08-31 19:57:49 -07:00
Ozzie Gooen
6631c9bad7 Renamed getByWithFn 2022-08-31 19:56:12 -07:00
Quinn Dougherty
cd20bef11d Merge remote-tracking branch 'origin/develop' into getByWithFn 2022-09-01 08:27:54 +08:00
Conor Barnes
2087a30b6b use in multiple plots 2022-08-31 12:15:43 -03:00
Conor Barnes
bc64d2882f more elegantly handle samples, properly use sample data in SampleSets for bands 2022-08-31 11:19:11 -03:00
Ozzie Gooen
a9dd18cbcd
Merge pull request #1034 from quantified-uncertainty/nix-cached-ci
`ci-cachix.yml`
2022-08-31 07:04:34 -07:00
Quinn Dougherty
39a9cd4eb9 a few unit tests 2022-08-31 10:31:32 +08:00
Ozzie Gooen
22458aa9e5 Proper formatting 2022-08-30 18:17:00 -07:00
Ozzie Gooen
2f77888365 Changed getByWithFn to not need two function calls 2022-08-30 17:58:51 -07:00
Conor Barnes
07b7b26d60 include sample band on sampleset story 2022-08-30 09:14:25 -03:00
Quinn Dougherty
2f525c4f8e put .#js in devshells job where it was supposed to be 2022-08-30 19:44:34 +08:00
Vyacheslav Matyukhin
ba280c9292
implement lambda calls in web components 2022-08-30 15:16:57 +04:00
Quinn Dougherty
02cbf227ad rescript-association merged the gentype flake, so our flake inputs are updated accordingly 2022-08-30 19:10:59 +08:00
Quinn Dougherty
4b6a565c33 minor cleanup 2022-08-30 17:12:50 +08:00
Quinn Dougherty
83ee5dfb63 cut down trad ci.yml by commenting out stuff covered by nix; added cli lint 2022-08-30 14:16:29 +08:00
Quinn Dougherty
3f50cde0a6 refactored shells nix code 2022-08-30 13:45:12 +08:00
Quinn Dougherty
37dfc49c58 a modest dag (2) 2022-08-30 13:25:02 +08:00
Quinn Dougherty
d6490be96f a modest dag 2022-08-30 13:23:32 +08:00
Quinn Dougherty
842157ee1b added devShell build to ci-cachix.yml 2022-08-30 13:18:35 +08:00
Quinn Dougherty
b89e4f1bd8 edited trigger conditions in two ci .yml files 2022-08-30 11:36:32 +08:00
Quinn Dougherty
b935621d2a changed @types/lodash version 2022-08-30 11:28:52 +08:00
Quinn Dougherty
905b5fc569 nixfmt compels me 2022-08-30 11:23:33 +08:00
Quinn Dougherty
21eeb63cf2 fix call to pkgs.writeText 2022-08-30 11:23:15 +08:00
Quinn Dougherty
05a7d5c09a rm need for @types/lodash in lang/package.json 2022-08-30 11:19:54 +08:00
Quinn Dougherty
73e1f0b206 rm spurious override of nixpkgs from flake-utils input; cleanup ci-cachix.yml 2022-08-30 09:34:35 +08:00
Quinn Dougherty
8319a484ac Merge remote-tracking branch 'origin/develop' into nix-cached-ci 2022-08-30 09:21:36 +08:00
Quinn
9a8ec06ca7
Merge pull request #1015 from quantified-uncertainty/factor-vscode-lint-to-prettier
rm eslint
2022-08-29 21:19:21 -04:00
Quinn Dougherty
39566696f6 manually fix yarn.lock for prettier action 2022-08-30 09:12:21 +08:00
Quinn Dougherty
e8e0332e2e Merge remote-tracking branch 'origin/develop' into factor-vscode-lint-to-prettier
Manually regenerated lockfile
2022-08-30 09:11:30 +08:00
Ozzie Gooen
c7bc526b38
Merge pull request #1033 from quantified-uncertainty/10k-to-1k-default
Changed samples and xyPointLength from 10K to 1K
2022-08-29 18:10:32 -07:00
dependabot[bot]
1c015599a8
Merge pull request #1021 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-4.8.2 2022-08-30 01:05:03 +00:00
Quinn Dougherty
4341d62893 fixed new bug 2022-08-30 08:55:45 +08:00
Ozzie Gooen
4368bb53fa
Changed samples and xyPointLength from 10K to 1K
See: https://eaforecasting.slack.com/archives/C030T49UHSS/p1661817834362619
2022-08-29 17:52:59 -07:00
Quinn Dougherty
228277d0e8 use prettier action instead of yarn 2022-08-30 08:34:50 +08:00
Quinn Dougherty
d137d6a2b4 manually fix problem with yarn.lock? 2022-08-30 08:28:45 +08:00
Quinn Dougherty
a83b46af25 regenerating lockfile isn't helping 2022-08-30 08:22:55 +08:00
Conor Barnes
a1db813b8b pr comment tweaks 2022-08-29 21:11:48 -03:00
Quinn Dougherty
4f3c84c8ac Merge remote-tracking branch 'origin/develop' into factor-vscode-lint-to-prettier
Piggybacked small changes to `./nixos.sh`
2022-08-30 08:07:35 +08:00
Conor Barnes
87c6ff1c3d width substitute 2022-08-29 20:32:32 -03:00
Vyacheslav Matyukhin
a7bbfad94b
store location in values; render both result and bindings 2022-08-30 01:51:44 +04:00
Conor Barnes
496bd0e539 storybook for date distribution, grab missing things necessary for date distribution in spec 2022-08-29 18:01:07 -03:00
Conor Barnes
0292c66c80 combined distribution chart component 2022-08-29 17:27:13 -03:00
Conor Barnes
7c00897833 don't let rule-line intercept hover events 2022-08-29 16:00:51 -03:00
Conor Barnes
e88d93ac9e more stringent logic over visibility of rule-line and announcer 2022-08-29 15:28:31 -03:00
Vyacheslav Matyukhin
ddfd4e0024
cleanup commented old code 2022-08-29 21:02:05 +04:00
dependabot[bot]
47ccba4c46
⬆️ Bump typescript from 4.7.4 to 4.8.2
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.4 to 4.8.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.7.4...v4.8.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 15:16:16 +00:00
Ozzie Gooen
d28a1ffe0b
Merge pull request #1020 from quantified-uncertainty/dependabot/npm_and_yarn/eslint-8.23.0
⬆️ Bump eslint from 8.22.0 to 8.23.0
2022-08-29 08:11:44 -07:00
dependabot[bot]
48409c7f82
⬆️ Bump eslint from 8.22.0 to 8.23.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.22.0 to 8.23.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.22.0...v8.23.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:59:45 +00:00
Ozzie Gooen
b3549348b0
Merge pull request #1027 from quantified-uncertainty/dependabot/npm_and_yarn/glennsl/rescript-jest-0.9.2
⬆️ Bump @glennsl/rescript-jest from 0.9.1 to 0.9.2
2022-08-29 07:58:23 -07:00
Ozzie Gooen
c52f3b9a55
Merge pull request #1026 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-eslint/parser-5.35.1
⬆️ Bump @typescript-eslint/parser from 5.33.1 to 5.35.1
2022-08-29 07:53:41 -07:00
Ozzie Gooen
2b846cae71
Merge pull request #1025 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.13
⬆️ Bump @types/node from 18.7.9 to 18.7.13
2022-08-29 07:53:31 -07:00
Ozzie Gooen
4d9eab8303
Merge pull request #1023 from quantified-uncertainty/dependabot/npm_and_yarn/web-vitals-3.0.0
⬆️ Bump web-vitals from 2.1.4 to 3.0.0
2022-08-29 07:53:24 -07:00
Ozzie Gooen
99551f7d1e
Merge pull request #1022 from quantified-uncertainty/dependabot/npm_and_yarn/floating-ui/react-dom-interactions-0.9.3
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.2 to 0.9.3
2022-08-29 07:53:15 -07:00
dependabot[bot]
745c8f9aeb
⬆️ Bump @typescript-eslint/parser from 5.33.1 to 5.35.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.33.1 to 5.35.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.35.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:40:13 +00:00
dependabot[bot]
ea053d4869
⬆️ Bump @types/node from 18.7.9 to 18.7.13
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.9 to 18.7.13.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:39:50 +00:00
Ozzie Gooen
7f7aefb129
Merge pull request #1019 from quantified-uncertainty/dependabot/npm_and_yarn/mathjs-11.1.0
⬆️ Bump mathjs from 11.0.1 to 11.1.0
2022-08-29 07:38:12 -07:00
Ozzie Gooen
377e99157c
Merge pull request #1018 from quantified-uncertainty/dependabot/npm_and_yarn/fast-check-3.1.2
⬆️ Bump fast-check from 3.1.1 to 3.1.2
2022-08-29 07:38:05 -07:00
Ozzie Gooen
59ff0c61dc
Merge pull request #1017 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.2.1
⬆️ Bump framer-motion from 7.2.0 to 7.2.1
2022-08-29 07:37:58 -07:00
dependabot[bot]
28067ffcbd
⬆️ Bump @glennsl/rescript-jest from 0.9.1 to 0.9.2
Bumps [@glennsl/rescript-jest](https://github.com/glennsl/rescript-jest) from 0.9.1 to 0.9.2.
- [Release notes](https://github.com/glennsl/rescript-jest/releases)
- [Commits](https://github.com/glennsl/rescript-jest/compare/v0.9.1...v0.9.2)

---
updated-dependencies:
- dependency-name: "@glennsl/rescript-jest"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:35:37 +00:00
Ozzie Gooen
ed7562c6c6
Merge pull request #1016 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.35.1
⬆️ Bump @typescript-eslint/eslint-plugin from 5.33.1 to 5.35.1
2022-08-29 07:32:46 -07:00
dependabot[bot]
790cffec8a
⬆️ Bump web-vitals from 2.1.4 to 3.0.0
Bumps [web-vitals](https://github.com/GoogleChrome/web-vitals) from 2.1.4 to 3.0.0.
- [Release notes](https://github.com/GoogleChrome/web-vitals/releases)
- [Changelog](https://github.com/GoogleChrome/web-vitals/blob/main/CHANGELOG.md)
- [Commits](https://github.com/GoogleChrome/web-vitals/compare/v2.1.4...v3.0.0)

---
updated-dependencies:
- dependency-name: web-vitals
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:31:20 +00:00
dependabot[bot]
92fb4c47c1
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.2 to 0.9.3
Bumps [@floating-ui/react-dom-interactions](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/react-dom-interactions) from 0.9.2 to 0.9.3.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/react-dom-interactions@0.9.3/packages/react-dom-interactions)

---
updated-dependencies:
- dependency-name: "@floating-ui/react-dom-interactions"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:30:36 +00:00
dependabot[bot]
1ce657d634
⬆️ Bump mathjs from 11.0.1 to 11.1.0
Bumps [mathjs](https://github.com/josdejong/mathjs) from 11.0.1 to 11.1.0.
- [Release notes](https://github.com/josdejong/mathjs/releases)
- [Changelog](https://github.com/josdejong/mathjs/blob/develop/HISTORY.md)
- [Commits](https://github.com/josdejong/mathjs/compare/v11.0.1...v11.1.0)

---
updated-dependencies:
- dependency-name: mathjs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:26:59 +00:00
dependabot[bot]
a68c3c0615
⬆️ Bump fast-check from 3.1.1 to 3.1.2
Bumps [fast-check](https://github.com/dubzzz/fast-check/tree/HEAD/packages/fast-check) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/dubzzz/fast-check/releases)
- [Changelog](https://github.com/dubzzz/fast-check/blob/main/packages/fast-check/CHANGELOG.md)
- [Commits](https://github.com/dubzzz/fast-check/commits/v3.1.2/packages/fast-check)

---
updated-dependencies:
- dependency-name: fast-check
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:26:20 +00:00
dependabot[bot]
353ea7e130
⬆️ Bump framer-motion from 7.2.0 to 7.2.1
Bumps [framer-motion](https://github.com/framer/motion) from 7.2.0 to 7.2.1.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.2.0...v7.2.1)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:25:49 +00:00
dependabot[bot]
1c0dc6af06
⬆️ Bump @typescript-eslint/eslint-plugin from 5.33.1 to 5.35.1
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.33.1 to 5.35.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.35.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 14:23:47 +00:00
Quinn Dougherty
b6a261bfb0 rm .eslintrc.json 2022-08-29 21:50:51 +08:00
Quinn Dougherty
06cd81eee3 rm eslint 2022-08-29 21:48:14 +08:00
Quinn Dougherty
9e342d884f init nix 2022-08-29 21:39:18 +08:00
Sam Nolan
e493437135 Remove hardcoded enum strings 2022-08-29 13:46:52 +10:00
Sam Nolan
25565ce5c0 Fix tests failing 2022-08-29 12:50:51 +10:00
Vyacheslav Matyukhin
9c3d41427e
update System.version 2022-08-29 00:01:26 +04:00
Vyacheslav Matyukhin
fe8e980d27
fix enum types; remove accidental generated .js file 2022-08-28 23:59:56 +04:00
Vyacheslav Matyukhin
b7aa126e6a
output bindings when result is void 2022-08-28 21:45:15 +04:00
Vyacheslav Matyukhin
481483e937
rename and stringify enum tags 2022-08-28 21:33:16 +04:00
Vyacheslav Matyukhin
b50061a91a
rename all TS classes 2022-08-28 20:19:44 +04:00
Vyacheslav Matyukhin
feeb9e85f1
fix typescript errors, basic playground features work 2022-08-28 00:02:13 +04:00
Vyacheslav Matyukhin
32cefb40da
TS & components (WIP) 2022-08-27 23:57:45 +04:00
Umur Ozkul
68ddf35387 format 2022-08-27 20:39:09 +02:00
Umur Ozkul
e18a06f584 get parameters 2022-08-27 20:38:46 +02:00
Umur Ozkul
687576547c fix lambda toString 2022-08-27 20:36:15 +02:00
Umur Ozkul
dd363d1e45 lambda parameters 2022-08-27 20:35:37 +02:00
Umur Ozkul
e2491bda88 toString for each squiggleValue 2022-08-27 20:24:13 +02:00
Umur Ozkul
2fc325beb6 format 2022-08-27 20:23:49 +02:00
Umur Ozkul
eaa1f60555 ForTS_Dsitribution, proxies for DistributionOperation.Constructors 2022-08-27 20:12:36 +02:00
Umur Ozkul
934144fce8 fix toString 2022-08-27 19:39:13 +02:00
Umur Ozkul
7b4e38a983 consistent to string for every value 2022-08-27 19:34:08 +02:00
Umur Ozkul
efd4fd322c PR968 - start tutorials from 1 instead of 0 2022-08-27 18:36:18 +02:00
Quinn Dougherty
36c3a93d08 10.0.0 2022-08-27 10:37:01 +08:00
Quinn Dougherty
f67abe55a8 Merge remote-tracking branch 'origin/develop' into experiment-10.0rc1 2022-08-27 10:33:48 +08:00
Umur Ozkul
a8efd66fa3 handle topology changes in the project 2022-08-26 02:01:27 +02:00
Umur Ozkul
0a8afc66a4 fix Topology test 2022-08-26 01:32:38 +02:00
Umur Ozkul
4e5e05530e Fix topology runOrderDiff 2022-08-26 00:45:13 +02:00
Umur Ozkul
ac63b57478 Merge branch 'develop' into epic-reducer-project 2022-08-26 00:09:50 +02:00
Ozzie Gooen
668756f874
Merge pull request #1010 from quantified-uncertainty/issue-1007
fix #1007
2022-08-25 13:34:09 -07:00
Umur Ozkul
d29b77ca61 fix #1007
variables that start with true/false
2022-08-25 22:19:29 +02:00
Umur Ozkul
2d59898b4f topology work in progress 2022-08-25 21:59:15 +02:00
Umur Ozkul
9a536d2a38 spell check 2022-08-25 20:56:27 +02:00
Ozzie Gooen
05299c78e6
Merge pull request #968 from quantified-uncertainty/reducer-project
Reducer Project - API Revamp
2022-08-25 08:31:56 -07:00
Vyacheslav Matyukhin
1f22d1f837
non-opaque results 2022-08-25 17:47:41 +04:00
Vyacheslav Matyukhin
7dd9a5bb77
string enum for SquiggleValue tags 2022-08-25 17:47:28 +04:00
Umur Ozkul
1dfc9fe820 RENeedToRun->Error 2022-08-25 10:43:51 +02:00
Conor Barnes
754fc8531f combined distribution chart component 2022-08-24 21:45:46 -03:00
Conor Barnes
a9e43ee7cf bring back the stems 2022-08-24 21:13:50 -03:00
Conor Barnes
a99ee96f5c announce x-axis date properly 2022-08-24 20:56:22 -03:00
Conor Barnes
f8e5396d57 use domain to feed sample for bottom band 2022-08-24 15:26:47 -03:00
Conor Barnes
865b01f48d significant digits on hover value 2022-08-24 13:57:35 -03:00
Umur Ozkul
b2fa0db627 Merge branch 'develop' into reducer-project 2022-08-24 12:24:31 +02:00
Conor Barnes
10db239920 hover line 2022-08-23 12:04:35 -03:00
Conor Barnes
d0468f9ea3 sample points below 2022-08-23 11:05:02 -03:00
Quinn
6a2ff40279
Replace algolia app
They ended up giving us premium for free (I think: the dashboard is pretty bad so it's hard to tell), so I'm replacing the algolia app with another one.
2022-08-23 08:59:52 -04:00
Umur Ozkul
441854ffec Merge branch 'develop' into reducer-project 2022-08-23 14:46:37 +02:00
Umur Ozkul
8de8cc3633 tutorial calling functions 2022-08-23 14:01:07 +02:00
Umur Ozkul
22e45d0e7b tutorial injecting user values 2022-08-23 13:39:19 +02:00
Umur Ozkul
5bc4395ff6 spelling 2022-08-23 13:25:02 +02:00
Umur Ozkul
d37f0fe117 tutorial includes final 2022-08-23 13:18:56 +02:00
Umur Ozkul
63cc9353b1 initial includes tutorial 2022-08-23 12:22:35 +02:00
Umur Ozkul
cd205f2eb9 test for parseInclude 2022-08-23 11:48:22 +02:00
Umur Ozkul
9cf3a93b70 fix parseInludes bug 2022-08-23 11:47:24 +02:00
Umur Ozkul
b7ae9804a5 format 2022-08-23 09:38:12 +02:00
Umur Ozkul
a394e93e06 tutorial intro to includes 2022-08-23 09:35:29 +02:00
Umur Ozkul
f23e26fbbf tutorial 1 depending 2022-08-23 09:20:18 +02:00
Ozzie Gooen
b8d7737aeb
Merge pull request #972 from quantified-uncertainty/pointset-mapy
Pointset mapY
2022-08-22 11:28:12 -07:00
Vyacheslav Matyukhin
59573e60f2
Merge pull request #1004 from orpheuslummis/orpheus/fix/vscode-ext-repo-link
fix: Update vscode ext manifest repository link
2022-08-22 20:34:52 +04:00
Orpheus Lummis
063b6b67a1 fix: Update vscode ext manifest repository link 2022-08-22 11:08:51 -05:00
Umur Ozkul
1250e66fb0 fix RT 2022-08-22 17:24:58 +02:00
dependabot[bot]
ae20ba8a70
Merge pull request #1000 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.9 2022-08-22 15:10:55 +00:00
dependabot[bot]
7eec5b397c
⬆️ Bump @types/node from 18.7.4 to 18.7.9
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.7.4 to 18.7.9.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 15:03:39 +00:00
Ozzie Gooen
2b92341257
Merge pull request #1001 from quantified-uncertainty/dependabot/npm_and_yarn/react-hook-form-7.34.2
⬆️ Bump react-hook-form from 7.34.1 to 7.34.2
2022-08-22 08:01:48 -07:00
Ozzie Gooen
8be02f3344
Merge pull request #999 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.2.0
⬆️ Bump framer-motion from 7.1.1 to 7.2.0
2022-08-22 08:01:32 -07:00
Ozzie Gooen
267c610263
Merge pull request #998 from quantified-uncertainty/dependabot/npm_and_yarn/vega-lite-5.5.0
⬆️ Bump vega-lite from 5.4.0 to 5.5.0
2022-08-22 08:00:45 -07:00
Conor Barnes
90ad0fdbdc announcer for hover values 2022-08-22 12:00:28 -03:00
Ozzie Gooen
90b8c083df
Merge pull request #997 from quantified-uncertainty/dependabot/npm_and_yarn/types/lodash-4.14.184
⬆️ Bump @types/lodash from 4.14.182 to 4.14.184
2022-08-22 08:00:26 -07:00
Ozzie Gooen
49429fcff8
Merge pull request #996 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-eslint/parser-5.33.1
⬆️ Bump @typescript-eslint/parser from 5.33.0 to 5.33.1
2022-08-22 08:00:17 -07:00
Conor Barnes
376e272c08 add offset 2022-08-22 11:42:21 -03:00
dependabot[bot]
fabd8daf9a
⬆️ Bump react-hook-form from 7.34.1 to 7.34.2
Bumps [react-hook-form](https://github.com/react-hook-form/react-hook-form) from 7.34.1 to 7.34.2.
- [Release notes](https://github.com/react-hook-form/react-hook-form/releases)
- [Changelog](https://github.com/react-hook-form/react-hook-form/blob/master/CHANGELOG.md)
- [Commits](https://github.com/react-hook-form/react-hook-form/compare/v7.34.1...v7.34.2)

---
updated-dependencies:
- dependency-name: react-hook-form
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 14:27:31 +00:00
dependabot[bot]
2eb011d965
⬆️ Bump framer-motion from 7.1.1 to 7.2.0
Bumps [framer-motion](https://github.com/framer/motion) from 7.1.1 to 7.2.0.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.1.1...v7.2.0)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 14:23:50 +00:00
dependabot[bot]
6b46817f70
⬆️ Bump vega-lite from 5.4.0 to 5.5.0
Bumps [vega-lite](https://github.com/vega/vega-lite) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/vega/vega-lite/releases)
- [Changelog](https://github.com/vega/vega-lite/blob/v5.5.0/CHANGELOG.md)
- [Commits](https://github.com/vega/vega-lite/compare/v5.4.0...v5.5.0)

---
updated-dependencies:
- dependency-name: vega-lite
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 14:22:54 +00:00
dependabot[bot]
e205133c8e
⬆️ Bump @types/lodash from 4.14.182 to 4.14.184
Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.14.182 to 4.14.184.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash)

---
updated-dependencies:
- dependency-name: "@types/lodash"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 14:22:07 +00:00
dependabot[bot]
9bffa25dea
⬆️ Bump @typescript-eslint/parser from 5.33.0 to 5.33.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.33.0 to 5.33.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.33.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 14:20:27 +00:00
Umur Ozkul
e6464dbe5c make ts compatible
commit 94803421acd2e5cb3a0f88e10f9244d374fab20b
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 08:48:33 2022 +0200

    note on old habbits

commit 2c47f80fce8fa6c12cb53b97f7150758eaa74b88
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 08:18:16 2022 +0200

    getTag returns enum value

commit 733b9a820f1d01b618708896451a112d638ee811
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 07:07:30 2022 +0200

    result

commit 64698f4a930182b3ccf122849824e4b6df251a9f
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:48:30 2022 +0200

    return tags as ts enum

commit 8ac802428a7aaac5367f5e8a9aaa592b89e305eb
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:16:26 2022 +0200

    export tags

commit 6c843e475a98ca1fcfa893d09d45ac9ad7c633ee
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 06:11:00 2022 +0200

    distribution tag

commit 9a43ec30fcaf967a672475431243949748d00bc7
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 05:46:24 2022 +0200

    opaque result

commit f89bdd47c41135135baac99b18faf1c418cc4142
Author: Umur Ozkul <umur@hightechmind.io>
Date:   Mon Aug 22 05:24:18 2022 +0200

    make ts compilable

    commit 6609bb3691b08405639e6f20da0fad309f2f232e
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 05:21:34 2022 +0200

        compiles

    commit bace3eca63079de8f285069c65b219601e7310bf
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 04:33:34 2022 +0200

        rescript compiles

    commit cd095f605c543902edec08fdcd407600296ec0cb
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 02:40:31 2022 +0200

        squiggleValue

    commit 9b78b5d6c8b69287458fe392f142ceb3bca99407
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 02:37:11 2022 +0200

        project

    commit 20c8693b1eb6492f1662bedbb26b469aac11f8ff
    Author: Umur Ozkul <umur@hightechmind.io>
    Date:   Mon Aug 22 00:59:44 2022 +0200

        compiles
2022-08-22 08:50:59 +02:00
Ozzie Gooen
e1efefaf7d Added sampleN from Stdlib to allow for correct sampling of discrete distributions 2022-08-21 21:45:05 -07:00
Ozzie Gooen
7237f2709b First implementation of sampleSet mixed distribution 2022-08-20 20:32:41 -07:00
Ozzie Gooen
516f4fa39d Added truncate for SampleSet distribution 2022-08-20 17:10:08 -07:00
Ozzie Gooen
72b1d6af3e Formatted 2022-08-20 15:59:25 -07:00
Ozzie Gooen
15debbddea Added very minimal documentation for PointSet mapY 2022-08-20 15:56:59 -07:00
Ozzie Gooen
a04761226d Improved error messages of function library 2022-08-20 15:50:30 -07:00
Umur Ozkul
25fb6dec82 Merge branch 'develop' into reducer-project 2022-08-20 08:12:56 +02:00
Umur Ozkul
c380ee2206 toStringResult for easy testing 2022-08-20 08:11:20 +02:00
Umur Ozkul
347c85324b opaque distribution type 2022-08-20 07:37:38 +02:00
Umur Ozkul
feb7627ad0 result fmap 2022-08-20 06:47:23 +02:00
Quinn
c3bb0ba291
Merge pull request #992 from quantified-uncertainty/algolia
docs site: algolia search
2022-08-19 20:19:40 -04:00
Umur Ozkul
ddb6d7f958 remove opaque type violations 2022-08-19 23:20:45 +02:00
Umur Ozkul
7957b89bb4 remove opaque type violations 2022-08-19 23:19:30 +02:00
Umur Ozkul
05ce6d2872 Comment opaue type violations 2022-08-19 23:01:38 +02:00
Umur Ozkul
bc86988453 Merge branch 'develop' into reducer-project 2022-08-19 22:35:32 +02:00
Umur Ozkul
4bf5f33f25 result tag 2022-08-19 22:03:55 +02:00
Umur Ozkul
5c75da4736 TypescriptInterface functions 2022-08-19 21:58:06 +02:00
Umur Ozkul
d7ed875566 demolish external value 2022-08-19 21:12:04 +02:00
Umur Ozkul
f573c326d2 demolish ExternalValue 2022-08-19 21:01:02 +02:00
Umur Ozkul
decc12637f bind common type 2022-08-19 20:23:30 +02:00
Umur Ozkul
a9ce3ca40d fix errorValue 2022-08-19 20:11:43 +02:00
Vyacheslav Matyukhin
bb4a108e59
Merge pull request #993 from quantified-uncertainty/fix-playground
Fix playground
2022-08-19 22:09:53 +04:00
Umur Ozkul
3e3ae50498 fix getIncldues result 2022-08-19 20:09:26 +02:00
Vyacheslav Matyukhin
c468457052
update squiggle-components version (fixes playground) 2022-08-19 21:54:29 +04:00
Umur Ozkul
14ceaa2667 missing genType 2022-08-19 19:54:20 +02:00
Vyacheslav Matyukhin
514af05fc2
Merge pull request #824 from quantified-uncertainty/multiple-charts
Add multiple plotting
2022-08-19 21:45:52 +04:00
Vyacheslav Matyukhin
bf02f69aca
legends, blues colors scheme, remove color setting 2022-08-19 21:14:08 +04:00
Umur Ozkul
3c1a49e44d index.ts 2022-08-19 18:44:32 +02:00
Umur Ozkul
610fa0227e opaque result 2022-08-19 18:28:03 +02:00
Umur Ozkul
bc7f1317da fix project test 2022-08-19 18:27:50 +02:00
Umur Ozkul
975b1ffda8 error value 2022-08-19 18:04:24 +02:00
Umur Ozkul
e9c55fe802 demolish FFI 2022-08-19 17:33:37 +02:00
Umur Ozkul
af4070a34f demolish external expression value 2022-08-19 17:30:29 +02:00
Umur Ozkul
f0ba68f64a project 2022-08-19 17:22:22 +02:00
Vyacheslav Matyukhin
fc29a7211e
minor improvements 2022-08-19 15:17:41 +04:00
Vyacheslav Matyukhin
7866203ac4
reimplement parsePlot with yup 2022-08-19 15:17:31 +04:00
Vyacheslav Matyukhin
61051ffe5f
multiple plots story 2022-08-19 15:15:43 +04:00
Quinn Dougherty
127fbe50a2 docs site: algolia search 2022-08-18 15:13:23 -07:00
Umur Ozkul
fdc7f06f08 result 2022-08-18 15:33:01 +02:00
Umur Ozkul
868f9f428a parametric types for typescript 2022-08-17 21:22:10 +02:00
Umur Ozkul
55c03ed520 missing gentype 2022-08-17 19:32:11 +02:00
Umur Ozkul
a8c7297621 TypeScript experiment 2022-08-17 18:57:34 +02:00
Umur Ozkul
3f92e7c3e1 Merge branch 'reducer-project' of github.com:quantified-uncertainty/squiggle into reducer-project 2022-08-16 19:02:05 +02:00
Umur Ozkul
32f3aeba13 tutorial TODO 2022-08-16 19:01:47 +02:00
Vyacheslav Matyukhin
c204156b75
fix gentype issues with "this" keyword 2022-08-16 20:58:47 +04:00
Umur Ozkul
454a545ef6 tutorial: initial
Also missing public API function
2022-08-16 17:07:15 +02:00
Vyacheslav Matyukhin
716ec61913
fix some gentype errors 2022-08-16 16:02:23 +04:00
Umur Ozkul
dc642774eb reformat 2022-08-16 02:49:16 +02:00
Umur Ozkul
b3a32b1231 more typescript friendly 2022-08-16 02:14:45 +02:00
Umur Ozkul
ee17bd9e57 more typescript friendly & remove an unnecessary call 2022-08-16 01:51:01 +02:00
Umur Ozkul
966fc7ad98 Merge branch 'develop' into reducer-project 2022-08-15 20:22:03 +02:00
dependabot[bot]
7925ffd640
Merge pull request #989 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.33.1 2022-08-15 18:02:30 +00:00
dependabot[bot]
6bed1cb7de
⬆️ Bump @typescript-eslint/eslint-plugin from 5.32.0 to 5.33.1
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.32.0 to 5.33.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.33.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 17:54:58 +00:00
Quinn
10ae50aeb6
Merge pull request #979 from quantified-uncertainty/dependabot/npm_and_yarn/types/styled-components-5.1.26
⬆️ Bump @types/styled-components from 5.1.25 to 5.1.26
2022-08-15 13:53:41 -04:00
Quinn
b21a19015a
Merge pull request #984 from quantified-uncertainty/dependabot/npm_and_yarn/typescript-eslint/parser-5.33.0
⬆️ Bump @typescript-eslint/parser from 5.32.0 to 5.33.0
2022-08-15 13:53:07 -04:00
dependabot[bot]
7c92808c67
⬆️ Bump @types/styled-components from 5.1.25 to 5.1.26
Bumps [@types/styled-components](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/styled-components) from 5.1.25 to 5.1.26.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/styled-components)

---
updated-dependencies:
- dependency-name: "@types/styled-components"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 15:01:43 +00:00
dependabot[bot]
bef4dc91f2
⬆️ Bump @typescript-eslint/parser from 5.32.0 to 5.33.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.32.0 to 5.33.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.33.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 15:00:01 +00:00
Ozzie Gooen
d21704e667
Merge pull request #978 from quantified-uncertainty/dependabot/npm_and_yarn/floating-ui/react-dom-interactions-0.9.2
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.1 to 0.9.2
2022-08-15 07:58:41 -07:00
Ozzie Gooen
7ebb66bb4a
Merge pull request #981 from quantified-uncertainty/dependabot/npm_and_yarn/react-hook-form-7.34.1
⬆️ Bump react-hook-form from 7.34.0 to 7.34.1
2022-08-15 07:58:26 -07:00
Ozzie Gooen
0a5c655b5b
Merge pull request #983 from quantified-uncertainty/dependabot/npm_and_yarn/framer-motion-7.1.1
⬆️ Bump framer-motion from 7.0.0 to 7.1.1
2022-08-15 07:58:17 -07:00
Ozzie Gooen
ef5906db52
Merge pull request #985 from quantified-uncertainty/dependabot/npm_and_yarn/webpack-dev-server-4.10.0
⬆️ Bump webpack-dev-server from 4.9.3 to 4.10.0
2022-08-15 07:58:05 -07:00
Ozzie Gooen
6c1513f65b
Merge pull request #986 from quantified-uncertainty/dependabot/npm_and_yarn/types/node-18.7.4
⬆️ Bump @types/node from 18.6.4 to 18.7.4
2022-08-15 07:57:58 -07:00
Ozzie Gooen
1b9f11612b
Merge pull request #987 from quantified-uncertainty/dependabot/npm_and_yarn/eslint-8.22.0
⬆️ Bump eslint from 8.21.0 to 8.22.0
2022-08-15 07:57:50 -07:00
Ozzie Gooen
bce8daf43c
Merge pull request #988 from quantified-uncertainty/dependabot/npm_and_yarn/testing-library/user-event-14.4.3
⬆️ Bump @testing-library/user-event from 14.4.2 to 14.4.3
2022-08-15 07:57:43 -07:00
dependabot[bot]
39b37960dd
⬆️ Bump @testing-library/user-event from 14.4.2 to 14.4.3
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.4.2 to 14.4.3.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.4.2...v14.4.3)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:45:23 +00:00
dependabot[bot]
00c6ea7d3e
⬆️ Bump eslint from 8.21.0 to 8.22.0
Bumps [eslint](https://github.com/eslint/eslint) from 8.21.0 to 8.22.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.21.0...v8.22.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:44:53 +00:00
dependabot[bot]
e7bae5fcb5
⬆️ Bump @types/node from 18.6.4 to 18.7.4
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.6.4 to 18.7.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:44:23 +00:00
dependabot[bot]
a1e79422a9
⬆️ Bump webpack-dev-server from 4.9.3 to 4.10.0
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.9.3 to 4.10.0.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.9.3...v4.10.0)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:43:38 +00:00
dependabot[bot]
1d9d24e08c
⬆️ Bump framer-motion from 7.0.0 to 7.1.1
Bumps [framer-motion](https://github.com/framer/motion) from 7.0.0 to 7.1.1.
- [Release notes](https://github.com/framer/motion/releases)
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v7.0.0...v7.1.1)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:41:28 +00:00
dependabot[bot]
5e16c2f76e
⬆️ Bump react-hook-form from 7.34.0 to 7.34.1
Bumps [react-hook-form](https://github.com/react-hook-form/react-hook-form) from 7.34.0 to 7.34.1.
- [Release notes](https://github.com/react-hook-form/react-hook-form/releases)
- [Changelog](https://github.com/react-hook-form/react-hook-form/blob/master/CHANGELOG.md)
- [Commits](https://github.com/react-hook-form/react-hook-form/compare/v7.34.0...v7.34.1)

---
updated-dependencies:
- dependency-name: react-hook-form
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:40:22 +00:00
dependabot[bot]
b55bd59219
⬆️ Bump @floating-ui/react-dom-interactions from 0.9.1 to 0.9.2
Bumps [@floating-ui/react-dom-interactions](https://github.com/floating-ui/floating-ui/tree/HEAD/packages/react-dom-interactions) from 0.9.1 to 0.9.2.
- [Release notes](https://github.com/floating-ui/floating-ui/releases)
- [Commits](https://github.com/floating-ui/floating-ui/commits/@floating-ui/react-dom-interactions@0.9.2/packages/react-dom-interactions)

---
updated-dependencies:
- dependency-name: "@floating-ui/react-dom-interactions"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 14:39:20 +00:00
Umur Ozkul
1b69ce3aa1 compatibility to change environment at runtime
There will be changes in develop to change environment at runtime. This
fix provides compatibility. So that they can be merged easier.
2022-08-15 15:18:14 +02:00
Umur Ozkul
66f2f18a00 fix merging develop 2022-08-15 14:45:45 +02:00
Umur Ozkul
58e1cf187d Merge branch 'develop' into reducer-project 2022-08-15 13:59:07 +02:00
Umur Ozkul
9075b74536 Edit comments 2022-08-14 17:40:52 +02:00
Umur Ozkul
0c1c5c9499 seperate Project Topology Module 2022-08-14 16:18:07 +02:00
Sam Nolan
e7a1fe1c17 Merge branch 'develop' into multiple-charts 2022-08-13 10:53:09 +01:00
Sam Nolan
70f26a08ba Fix multiple charting 2022-08-13 10:52:56 +01:00
Ozzie Gooen
5dd988ac13
Merge pull request #900 from quantified-uncertainty/reducer-typecheck-example
Reducer real life type checking example to build a library
2022-08-11 17:45:30 -07:00
Sam Nolan
c97d1d457e Remove unneccesary line 2022-08-11 14:22:55 +01:00
Sam Nolan
4aab78b45c Format code 2022-08-11 12:31:44 +01:00
Sam Nolan
ffb9e85d75 Merge branch 'develop' into multiple-charts 2022-08-11 12:29:08 +01:00
Sam Nolan
ba59047d31 Merge branch 'develop' into multiple-charts 2022-08-11 12:12:59 +01:00
Umur Ozkul
f21725d86c remove TODO 2022-08-10 12:09:06 +02:00
Umur Ozkul
2e8e71bbd0 project
test

remove setResult

parse end of outerblock

test end of outer block

compiles

testing

bindings tested

todo chain bindings

topological sort
2022-08-10 11:53:39 +02:00
Quinn
07af79adc8
bump rescript and @rescript/std to 10.0.0-rc.1 2022-08-08 14:54:57 -04:00
Ozzie Gooen
2aaa43008d Very simple implementation of pointset mapY 2022-08-08 10:31:05 -07:00
Umur Ozkul
c6eb69628d merge issue 904 2022-07-29 05:53:47 +02:00
Umur Ozkul
1a5f8dee72 Merge branch 'develop' into reducer-typecheck-example 2022-07-29 05:52:35 +02:00
Umur Ozkul
e1c53c9087 any type
any will be depreciated after the implementation of binding type
variables
2022-07-28 22:25:51 +02:00
Umur Ozkul
6733319403 switch replacement by type checking 2022-07-28 22:20:00 +02:00
Umur Ozkul
fc88b065f5 remove unused test file 2022-07-28 13:42:27 +02:00
Sam Nolan
b71823b4c5 Merge branch 'develop' into multiple-charts 2022-07-19 11:42:44 +10:00
Sam Nolan
7e33ea1fe7 Merge branch 'develop' into multiple-charts 2022-07-19 11:40:59 +10:00
Sam Nolan
ad1d391f49 Rename plotting to plotParser 2022-07-14 16:36:12 +10:00
Sam Nolan
9cc000070b Refactor parsing to lib files 2022-07-13 15:54:45 +10:00
Sam Nolan
a5a131daf1 Remove console.log 2022-07-13 15:33:38 +10:00
Sam Nolan
0c7ac98aaf Color discrete components of distributions 2022-07-13 15:32:28 +10:00
Sam Nolan
b536637c98 Make parser of distributions stricter 2022-07-13 15:29:39 +10:00
Sam Nolan
98ae0459c9 Refactor specification to include discrete 2022-07-13 14:15:07 +10:00
Sam Nolan
9cbeee0451 Add multiple plotting 2022-07-12 17:09:24 +10:00
323 changed files with 14970 additions and 11460 deletions

20
.github/CODEOWNERS vendored
View File

@ -9,22 +9,22 @@
# This also holds true for GitHub teams. # This also holds true for GitHub teams.
# Rescript # Rescript
*.res @OAGr *.res @berekuk @OAGr
*.resi @OAGr *.resi @berekuk @OAGr
# Typescript # Typescript
*.tsx @Hazelfire @OAGr *.tsx @Hazelfire @berekuk @OAGr
*.ts @Hazelfire @OAGr *.ts @Hazelfire @berekuk @OAGr
# Javascript # Javascript
*.js @Hazelfire @OAGr *.js @Hazelfire @berekuk @OAGr
# Any opsy files # Any opsy files
.github/** @quinn-dougherty @OAGr .github/** @quinn-dougherty @berekuk @OAGr
*.json @quinn-dougherty @Hazelfire @OAGr *.json @quinn-dougherty @Hazelfire @berekuk @OAGr
*.y*ml @quinn-dougherty @OAGr *.y*ml @quinn-dougherty @berekuk @OAGr
*.config.js @Hazelfire @OAGr *.config.js @Hazelfire @berekuk @OAGr
netlify.toml @quinn-dougherty @OAGr @Hazelfire vercel.json @OAGr @berekuk @Hazelfire
# Documentation # Documentation
*.md @quinn-dougherty @OAGr @Hazelfire *.md @quinn-dougherty @OAGr @Hazelfire

View File

@ -12,9 +12,13 @@ updates:
commit-message: commit-message:
prefix: "⬆️" prefix: "⬆️"
open-pull-requests-limit: 100 open-pull-requests-limit: 100
labels:
- "dependencies"
- package-ecosystem: "github-actions" - package-ecosystem: "github-actions"
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
commit-message: commit-message:
prefix: "⬆️" prefix: "⬆️"
labels:
- "dependencies"

87
.github/workflows/ci-cachix.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: Nix build
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
- reducer-dev
- epic-reducer-project
jobs:
flake-lints:
name: All lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-22.05
- name: Use cachix
uses: cachix/cachix-action@v10
with:
name: quantified-uncertainty
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Check that lang lints
run: nix build .#lang-lint
- name: Check that components lints
run: nix build .#components-lint
- name: Check that website lints
run: nix build .#docusaurus-lint
- name: Check that vscode extension lints
run: nix build .#vscode-lint
- name: Check that cli lints
run: nix build .#cli-lint
flake-packages:
name: Builds, tests, and bundles
runs-on: ubuntu-latest
needs: flake-lints
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-22.05
- name: Use cachix
uses: cachix/cachix-action@v10
with:
name: quantified-uncertainty
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Check all lang tests
run: nix build .#lang-test
- name: Check that lang bundles
run: nix build .#lang-bundle
- name: Check that components builds
run: nix build .#components
- name: Check that components bundles
run: nix build .#components-bundle
flake-devshells:
name: Development shell environment
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-22.05
- name: Use cachix
uses: cachix/cachix-action@v10
with:
name: quantified-uncertainty
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build js devshell
run: nix develop .#js --profile just-js
- name: Build js & wasm devshell
run: nix develop --profile full-shell

View File

@ -1,4 +1,4 @@
name: Squiggle packages check name: Squiggle packages checks
on: on:
push: push:
@ -9,213 +9,40 @@ on:
branches: branches:
- master - master
- develop - develop
- reducer-dev
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: quantified-uncertainty
jobs: jobs:
pre_check: build-test-lint:
name: Precheck for skipping redundant jobs name: Build, test, lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
should_skip_lang: ${{ steps.skip_lang_check.outputs.should_skip }}
should_skip_components: ${{ steps.skip_components_check.outputs.should_skip }}
should_skip_website: ${{ steps.skip_website_check.outputs.should_skip }}
should_skip_vscodeext: ${{ steps.skip_vscodeext_check.outputs.should_skip }}
should_skip_cli: ${{ steps.skip_cli_check.outputs.should_skip }}
steps:
- id: skip_lang_check
name: Check if the changes are about squiggle-lang src files
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/squiggle-lang/**"]'
- id: skip_components_check
name: Check if the changes are about components src files
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/components/**"]'
- id: skip_website_check
name: Check if the changes are about website src files
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/website/**"]'
- id: skip_vscodeext_check
name: Check if the changes are about vscode extension src files
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/vscode-ext/**"]'
- id: skip_cli_check
name: Check if the changes are about cli src files
uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/cli/**"]'
lang-lint:
name: Language lint
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/squiggle-lang
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install Dependencies - name: Setup Node.js environment
run: cd ../../ && yarn uses: actions/setup-node@v3
- name: Check rescript lint
run: yarn lint:rescript
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with: with:
dry: true node-version: 16
prettier_options: --check packages/squiggle-lang cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Turbo run
run: npx turbo run build test lint bundle
lang-build-test-bundle: coverage:
name: Language build, test, and bundle name: Coverage
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/squiggle-lang
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 2 fetch-depth: 2
- name: Install dependencies from monorepo level - name: Setup Node.js environment
run: cd ../../ && yarn uses: actions/setup-node@v2
- name: Build rescript codebase
run: yarn build
- name: Run rescript tests
run: yarn test:rescript
- name: Run typescript tests
run: yarn test:ts
- name: Run webpack
run: yarn bundle
- name: Upload rescript coverage report
run: yarn coverage:rescript:ci
- name: Upload typescript coverage report
run: yarn coverage:ts:ci
components-lint:
name: Components lint
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_components != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/components
steps:
- uses: actions/checkout@v3
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with: with:
dry: true node-version: 16
prettier_options: --check packages/components --ignore-path packages/components/.prettierignore cache: 'yarn'
- name: Install dependencies
components-bundle-build: run: yarn
name: Components bundle and build - name: Coverage
runs-on: ubuntu-latest run: npx turbo run coverage
needs: pre_check
if: ${{ (needs.pre_check.outputs.should_skip_components != 'true') || (needs.pre_check.outputs.should_skip_lang != 'true') }}
defaults:
run:
shell: bash
working-directory: packages/components
steps:
- uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript codebase in squiggle-lang
run: cd ../squiggle-lang && yarn build
- name: Run webpack
run: yarn bundle
- name: Build storybook
run: yarn build
website-lint:
name: Website lint
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_website != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/website
steps:
- uses: actions/checkout@v3
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with:
dry: true
prettier_options: --check packages/website
website-build:
name: Website build
runs-on: ubuntu-latest
needs: pre_check
if: ${{ (needs.pre_check.outputs.should_skip_website != 'true') || (needs.pre_check.outputs.should_skip_lang != 'true') || (needs.pre_check.outputs.should_skip_components != 'true') }}
defaults:
run:
shell: bash
working-directory: packages/website
steps:
- uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript in squiggle-lang
run: cd ../squiggle-lang && yarn build
- name: Build components
run: cd ../components && yarn build
- name: Build website assets
run: yarn build
vscode-ext-lint:
name: VS Code extension lint
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_vscodeext != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/vscode-ext
steps:
- uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Lint the VSCode Extension source code
run: yarn lint
vscode-ext-build:
name: VS Code extension build
runs-on: ubuntu-latest
needs: pre_check
if: ${{ (needs.pre_check.outputs.should_skip_components != 'true') || (needs.pre_check.outputs.should_skip_lang != 'true') }} || (needs.pre_check.outputs.should_skip_vscodeext != 'true') }}
defaults:
run:
shell: bash
working-directory: packages/vscode-ext
steps:
- uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build
run: yarn compile
cli-lint:
name: CLI lint
runs-on: ubuntu-latest
needs: pre_check
if: ${{ needs.pre_check.outputs.should_skip_cli != 'true' }}
defaults:
run:
shell: bash
working-directory: packages/cli
steps:
- uses: actions/checkout@v3
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with:
dry: true
prettier_options: --check packages/cli

View File

@ -3,7 +3,7 @@ name: Run Release Please
on: on:
push: push:
branches: branches:
- develop - master
jobs: jobs:
pre_check: pre_check:
@ -18,27 +18,27 @@ jobs:
steps: steps:
- id: skip_lang_check - id: skip_lang_check
name: Check if the changes are about squiggle-lang src files name: Check if the changes are about squiggle-lang src files
uses: fkirc/skip-duplicate-actions@v4.0.0 uses: fkirc/skip-duplicate-actions@v5.2.0
with: with:
paths: '["packages/squiggle-lang/**"]' paths: '["packages/squiggle-lang/**"]'
- id: skip_components_check - id: skip_components_check
name: Check if the changes are about components src files name: Check if the changes are about components src files
uses: fkirc/skip-duplicate-actions@v4.0.0 uses: fkirc/skip-duplicate-actions@v5.2.0
with: with:
paths: '["packages/components/**"]' paths: '["packages/components/**"]'
- id: skip_website_check - id: skip_website_check
name: Check if the changes are about website src files name: Check if the changes are about website src files
uses: fkirc/skip-duplicate-actions@v4.0.0 uses: fkirc/skip-duplicate-actions@v5.2.0
with: with:
paths: '["packages/website/**"]' paths: '["packages/website/**"]'
- id: skip_vscodeext_check - id: skip_vscodeext_check
name: Check if the changes are about vscode extension src files name: Check if the changes are about vscode extension src files
uses: fkirc/skip-duplicate-actions@v4.0.0 uses: fkirc/skip-duplicate-actions@v5.2.0
with: with:
paths: '["packages/vscode-ext/**"]' paths: '["packages/vscode-ext/**"]'
- id: skip_cli_check - id: skip_cli_check
name: Check if the changes are about cli src files name: Check if the changes are about cli src files
uses: fkirc/skip-duplicate-actions@v4.0.0 uses: fkirc/skip-duplicate-actions@v5.2.0
with: with:
paths: '["packages/cli/**"]' paths: '["packages/cli/**"]'
@ -55,21 +55,22 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}} token: ${{secrets.GITHUB_TOKEN}}
command: manifest-pr command: manifest-pr
path: packages/squiggle-lang path: packages/squiggle-lang
bump-patch-for-minor-pre-major: true # bump-patch-for-minor-pre-major: true
skip-github-release: true skip-github-release: true
# - name: Publish: Checkout source - name: Publish- Checkout source
# uses: actions/checkout@v2 uses: actions/checkout@v3
# # these if statements ensure that a publication only occurs when # these if statements ensure that a publication only occurs when
# # a new release is created: # a new release is created:
# if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
# - name: Publish: Install dependencies - name: Publish- Install dependencies
# run: yarn run: yarn
# if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
# - name: Publish - name: Publish
# run: cd packages/squiggle-lang && yarn publish run: cd packages/squiggle-lang && yarn publish
# env: env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
# if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
relplz-components: relplz-components:
name: for components name: for components
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -82,20 +83,20 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}} token: ${{secrets.GITHUB_TOKEN}}
command: manifest-pr command: manifest-pr
path: packages/components path: packages/components
bump-patch-for-minor-pre-major: true # bump-patch-for-minor-pre-major: true
skip-github-release: true skip-github-release: true
# - name: Publish: Checkout source - name: Publish- Checkout source
# uses: actions/checkout@v2 uses: actions/checkout@v3
# # these if statements ensure that a publication only occurs when # these if statements ensure that a publication only occurs when
# # a new release is created: # a new release is created:
# if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
# - name: Publish: Install dependencies - name: Publish- Install dependencies
# run: yarn run: yarn
# if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}
# - name: Publish - name: Publish
# run: cd packages/components && yarn publish run: cd packages/components && yarn publish
# env: env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
relplz-website: relplz-website:
name: for website name: for website
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -108,7 +109,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}} token: ${{secrets.GITHUB_TOKEN}}
command: manifest-pr command: manifest-pr
path: packages/website path: packages/website
bump-patch-for-minor-pre-major: true # bump-patch-for-minor-pre-major: true
skip-github-release: true skip-github-release: true
relplz-vscodeext: relplz-vscodeext:
name: for vscode-ext name: for vscode-ext
@ -122,7 +123,7 @@ jobs:
token: ${{secrets.GITHUB_TOKEN}} token: ${{secrets.GITHUB_TOKEN}}
command: manifest-pr command: manifest-pr
path: packages/vscode-ext path: packages/vscode-ext
bump-patch-for-minor-pre-major: true # bump-patch-for-minor-pre-major: true
skip-github-release: true skip-github-release: true
relplz-cl: relplz-cl:
name: for cli name: for cli

6
.gitignore vendored
View File

@ -7,3 +7,9 @@ yarn-error.log
**/.sync.ffs_db **/.sync.ffs_db
.direnv .direnv
.log .log
.vscode
todo.txt
result
shell.nix
.turbo

View File

@ -1,15 +1,16 @@
.direnv .direnv
*.bs.js *.bs.js
*.gen.tsx *.gen.tsx
packages/*/dist
packages/components/storybook-static packages/components/storybook-static
node_modules node_modules
packages/*/node_modules packages/*/node_modules
packages/website/.docusaurus packages/website/.docusaurus
packages/squiggle-lang/lib packages/squiggle-lang/lib
packages/squiggle-lang/.nyc_output/
packages/squiggle-lang/coverage/ packages/squiggle-lang/coverage/
packages/squiggle-lang/.cache/ packages/squiggle-lang/.cache/
packages/website/build/ packages/website/build/
packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_GeneratedParser.js packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_GeneratedParser.js
packages/vscode-ext/media/vendor/ packages/vscode-ext/media/vendor/
packages/squiggle-lang/.nyc_output/
packages/*/dist
result

View File

@ -1,7 +1,7 @@
{ {
"packages/cli": "0.0.3", "packages/cli": "0.0.3",
"packages/components": "0.3.1", "packages/components": "0.4.1",
"packages/squiggle-lang": "0.3.0", "packages/squiggle-lang": "0.4.1",
"packages/vscode-ext": "0.3.1", "packages/vscode-ext": "0.4.1",
"packages/website": "0.3.0" "packages/website": "0.0.0"
} }

1
CHANGELOG.md Normal file
View File

@ -0,0 +1 @@
See the [Changelog.mdx page](./packages/website/docs/Changelog.mdx) for the changelog.

View File

@ -16,7 +16,7 @@ Squiggle is currently pre-alpha.
# Bug reports # Bug reports
Anyone (with a github account) can file an issue at any time. Please allow Quinn, Sam, and Ozzie to triage, but otherwise just follow the suggestions in the issue templates. 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.
# Project structure # Project structure
@ -28,7 +28,7 @@ Squiggle is a **monorepo** with three **packages**.
# Deployment ops # Deployment ops
We use netlify, and it should only concern Quinn, Sam, and Ozzie. We use Vercel, and it should only concern Slava, Sam, and Ozzie.
# Development environment, building, testing, dev server # Development environment, building, testing, dev server
@ -56,9 +56,9 @@ If you absolutely must, please prefix your commit message with `hotfix: `.
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 rescript code: Slava and Ozzie are reviewers
- For js or typescript code: Sam and Ozzie are reviewers - For js or typescript code: Sam and Ozzie are reviewers
- For ops code (i.e. yaml, package.json): Quinn and Sam are reviewers - For ops code (i.e. yaml, package.json): Slava and Sam are reviewers
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. 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.

View File

@ -21,10 +21,10 @@ _An estimation language_.
## Our deployments ## Our deployments
- **website/docs prod**: https://squiggle-language.com [![Netlify Status](https://api.netlify.com/api/v1/badges/2139af5c-671d-473d-a9f6-66c96077d8a1/deploy-status)](https://app.netlify.com/sites/squiggle-documentation/deploys) - **website/docs prod**: https://squiggle-language.com
- **website/docs staging**: https://develop--squiggle-documentation.netlify.app/ - **website/docs staging**: https://preview.squiggle-language.com
- **components storybook prod**: https://squiggle-components.netlify.app/ [![Netlify Status](https://api.netlify.com/api/v1/badges/b7f724aa-6b20-4d0e-bf86-3fcd1a3e9a70/deploy-status)](https://app.netlify.com/sites/squiggle-components/deploys) - **components storybook prod**: https://components.squiggle-language.com
- **components storybook staging**: https://develop--squiggle-components.netlify.app/ - **components storybook staging**: https://preview-components.squiggle-language.com
- **legacy (2020) playground**: https://playground.squiggle-language.com - **legacy (2020) playground**: https://playground.squiggle-language.com
## Packages ## Packages
@ -51,7 +51,25 @@ For any project in the repo, begin by running `yarn` in the top level
yarn yarn
``` ```
See `packages/*/README.md` to work with whatever project you're interested in. Then use `turbo` to build the specific packages or the entire monorepo:
```sh
turbo run build
```
Or:
```sh
turbo run build --filter=@quri/squiggle-components
```
You can also run specific npm scripts for the package you're working on. See `packages/*/README.md` for the details.
# NixOS users
This repository requires the use of bundled binaries from node_modules, which
are not linked statically. The easiest way to get them working is to enable
[nix-ld](https://github.com/Mic92/nix-ld).
# Contributing # Contributing

79
flake.lock Normal file
View File

@ -0,0 +1,79 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gentype": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1661855866,
"narHash": "sha256-+q0OOTyaq8eOn9BOWdPOCtSDOISW4A59v3mq3JOZyug=",
"owner": "rescript-association",
"repo": "genType",
"rev": "6b5f164b4f6ced456019b7579a0ab7e0a86518ad",
"type": "github"
},
"original": {
"owner": "rescript-association",
"repo": "genType",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1661617163,
"narHash": "sha256-NN9Ky47j8ohgPhA9JZyfkYIbbAo6RJkGz+7h8/exVpE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0ba2543f8c855d7be8e90ef6c8dc89c1617e8a08",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"gentype": "gentype",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

99
flake.nix Normal file
View File

@ -0,0 +1,99 @@
{
description = "Squiggle packages";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
gentype = {
url = "github:rescript-association/genType";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, gentype, flake-utils }:
let
version = builtins.substring 0 8 self.lastModifiedDate;
overlays = [
(final: prev: {
# set the node version here
nodejs = prev.nodejs-18_x;
# The override is the only way to get it into mkYarnModules
})
];
commonFn = pkgs: {
buildInputs = with pkgs; [ nodejs yarn ];
prettier = with pkgs.nodePackages; [ prettier ];
which = [ pkgs.which ];
};
gentypeOutputFn = pkgs: gentype.outputs.packages.${pkgs.system}.default;
langFn = { pkgs, ... }:
# Probably doesn't work on i686-linux
import ./nix/squiggle-lang.nix {
inherit pkgs commonFn gentypeOutputFn;
};
componentsFn = { pkgs, ... }:
import ./nix/squiggle-components.nix { inherit pkgs commonFn langFn; };
websiteFn = { pkgs, ... }:
import ./nix/squiggle-website.nix {
inherit pkgs commonFn langFn componentsFn;
};
vscodeextFn = { pkgs, ... }:
import ./nix/squiggle-vscode.nix {
inherit pkgs commonFn langFn componentsFn;
};
cliFn = { pkgs, ... }:
import ./nix/squiggle-cli.nix {
inherit pkgs commonFn;
};
# local machines
localFlakeOutputs = { pkgs, ... }:
let
lang = langFn pkgs;
components = componentsFn pkgs;
website = websiteFn pkgs;
vscodeext = vscodeextFn pkgs;
cli = cliFn pkgs;
in {
# validating
checks = flake-utils.lib.flattenTree {
lang-lint = lang.lint;
lang-test = lang.test;
components-lint = components.lint;
docusaurus-lint = website.lint;
cli-lint = cli.lint;
};
# building
packages = flake-utils.lib.flattenTree {
default = components.build;
lang = lang.build;
lang-bundle = lang.bundle;
lang-test = lang.test;
components = components.build;
components-bundle = components.bundle;
# Lint
lang-lint = lang.lint;
components-lint = components.lint;
docusaurus-lint = website.lint;
vscode-lint = vscodeext.lint;
cli-lint = cli.lint;
};
# developing
devShells = let shellNix = import ./nix/shell.nix { inherit pkgs; };
in flake-utils.lib.flattenTree {
default = shellNix.all;
js = shellNix.just-js;
};
};
in flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = overlays;
};
in localFlakeOutputs pkgs);
}

1
nix/README.md Normal file
View File

@ -0,0 +1 @@
Visit `quantified-uncertainty.cachix.org` for information about how to add our binary cache to your local dev environment.

25
nix/shell.nix Normal file
View File

@ -0,0 +1,25 @@
{ pkgs }:
with pkgs;
let
js = [ yarn nodejs nodePackages.ts-node ];
rust = [
wasm-pack
cargo
rustup
pkg-config
libressl
rustfmt
wasmtime
binaryen
wasm-bindgen-cli
];
in {
all = mkShell {
name = "squiggle_yarn-wasm-devshell";
buildInputs = builtins.concatLists [ js rust [ nixfmt ] ];
};
just-js = mkShell {
name = "squiggle_yarn-devshell";
buildInputs = js ++ [ nixfmt ];
};
}

13
nix/squiggle-cli.nix Normal file
View File

@ -0,0 +1,13 @@
{ pkgs, commonFn }:
rec {
common = commonFn pkgs;
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-cli-lint";
buildInputs = common.buildInputs ++ common.prettier;
src = ../packages/cli;
buildPhase = "prettier --check .";
installPhase = "mkdir -p $out";
};
}

View File

@ -0,0 +1,75 @@
{ pkgs, commonFn, langFn }:
rec {
common = commonFn pkgs;
lang = langFn pkgs;
componentsPackageJson = let
raw = pkgs.lib.importJSON ../packages/components/package.json;
modified =
pkgs.lib.recursiveUpdate raw { dependencies.react-dom = "^18.2.0"; };
packageJsonString = builtins.toJSON modified;
in pkgs.writeText "packages/components/patched-package.json"
packageJsonString;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-components_yarnsource";
buildInputs = common.buildInputs;
src = ../packages/components;
packageJSON = componentsPackageJson;
yarnLock = ../yarn.lock;
packageResolutions."@quri/squiggle-lang" = lang.build;
};
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-components-lint";
src = ../packages/components;
buildInputs = common.buildInputs ++ common.prettier;
buildPhase = "yarn lint";
installPhase = "mkdir -p $out";
};
build = pkgs.stdenv.mkDerivation {
name = "squiggle-components-build";
src = yarn-source + "/libexec/@quri/squiggle-components";
buildInputs = common.buildInputs;
buildPhase = ''
cp -r node_modules/@quri/squiggle-lang deps/@quri
pushd deps/@quri/squiggle-components
yarn --offline build:cjs
yarn --offline build:css
popd
'';
installPhase = ''
mkdir -p $out
# annoying hack because permissions on transitive dependencies later on
mv deps/@quri/squiggle-components/node_modules deps/@quri/squiggle-components/NODE_MODULES
mv node_modules deps/@quri/squiggle-components
# patching .gitignore so flake keeps build artefacts
sed -i /dist/d deps/@quri/squiggle-components/.gitignore
cp -r deps/@quri/squiggle-components/. $out
'';
};
bundle = pkgs.stdenv.mkDerivation {
name = "squiggle-components-bundle";
src = yarn-source + "/libexec/@quri/squiggle-components";
buildInputs = common.buildInputs;
buildPhase = ''
cp -r node_modules/@quri/squiggle-lang deps/@quri
pushd deps/@quri/squiggle-components
yarn --offline bundle
popd
'';
installPhase = ''
mkdir -p $out
# annoying hack because permissions on transitive dependencies later on
mv deps/@quri/squiggle-components/node_modules deps/@quri/squiggle-components/NODE_MODULES
mv node_modules deps/@quri/squiggle-components
# patching .gitignore so flake keeps build artefacts
sed -i /dist/d deps/@quri/squiggle-components/.gitignore
cp -r deps/@quri/squiggle-components/. $out
'';
};
}

116
nix/squiggle-lang.nix Normal file
View File

@ -0,0 +1,116 @@
{ pkgs, commonFn, gentypeOutputFn }:
rec {
common = commonFn pkgs;
langPackageJson = let
raw = pkgs.lib.importJSON ../packages/squiggle-lang/package.json;
modified = pkgs.lib.recursiveUpdate raw {
devDependencies."@types/lodash" = "^4.14.167";
};
packageJsonString = builtins.toJSON modified;
in pkgs.writeText "packages/squiggle-lang/patched-package.json"
packageJsonString;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-lang_yarnsource";
src = ../packages/squiggle-lang;
packageJSON = langPackageJson;
yarnLock = ../yarn.lock;
pkgConfig = {
rescript = {
buildInputs = common.which
++ (if pkgs.system != "i686-linux" then [ pkgs.gcc_multi ] else [ ]);
postInstall = ''
echo "PATCHELF'ING RESCRIPT EXECUTABLES (INCL NINJA)"
# Patching interpreter for linux/*.exe's
THE_LD=$(patchelf --print-interpreter $(which mkdir))
patchelf --set-interpreter $THE_LD linux/*.exe && echo "- patched interpreter for linux/*.exe's"
# Replacing needed shared library for linux/ninja.exe
THE_SO=$(find /nix/store/*/lib64 -name libstdc++.so.6 | head -n 1)
patchelf --replace-needed libstdc++.so.6 $THE_SO linux/ninja.exe && echo "- replaced needed for linux/ninja.exe"
'';
};
gentype = {
postInstall = ''
mv gentype.exe ELFLESS-gentype.exe
cp ${gentypeOutputFn pkgs}/src/GenType.exe gentype.exe
'';
};
};
};
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-lint";
src = yarn-source + "/libexec/@quri/squiggle-lang/deps/@quri/squiggle-lang";
buildInputs = common.buildInputs ++ common.prettier;
buildPhase = ''
yarn lint:prettier
yarn lint:rescript
'';
installPhase = "mkdir -p $out";
};
build = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-build";
# `peggy` is in the `node_modules` that's adjacent to `deps`.
src = yarn-source + "/libexec/@quri/squiggle-lang";
buildInputs = common.buildInputs;
buildPhase = ''
# so that the path to ppx doesn't need to be patched.
mv node_modules deps
pushd deps/@quri/squiggle-lang
yarn --offline build:peggy
yarn --offline build:rescript
yarn --offline build:typescript
# custom gitignore so that the flake keeps build artefacts
mv .gitignore GITIGNORE
sed -i /Reducer_Peggy_GeneratedParser.js/d GITIGNORE
sed -i /ReducerProject_IncludeParser.js/d GITIGNORE
sed -i /\*.bs.js/d GITIGNORE
sed -i /\*.gen.ts/d GITIGNORE
sed -i /\*.gen.tsx/d GITIGNORE
sed -i /\*.gen.js/d GITIGNORE
sed -i /helpers.js/d GITIGNORE
popd
'';
installPhase = ''
mkdir -p $out
# mkdir -p $out/node_modules
mv deps/@quri/squiggle-lang/GITIGNORE deps/@quri/squiggle-lang/.gitignore
# annoying hack because permissions on transitive dependencies later on
mv deps/@quri/squiggle-lang/node_modules deps/@quri/squiggle-lang/NODE_MODULES
mv deps/node_modules deps/@quri/squiggle-lang
# the proper install phase
cp -r deps/@quri/squiggle-lang/. $out
'';
};
test = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-test";
src = build;
buildInputs = common.buildInputs;
buildPhase = ''
yarn --offline test
'';
installPhase = ''
mkdir -p $out
cp -r . $out
'';
};
bundle = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-bundle";
src = test;
buildInputs = common.buildInputs;
buildPhase = ''
yarn --offline bundle
'';
installPhase = ''
mkdir -p $out
cp -r dist $out
cp *.json $out/dist
'';
};
}

24
nix/squiggle-vscode.nix Normal file
View File

@ -0,0 +1,24 @@
{ pkgs, commonFn, langFn, componentsFn }:
rec {
common = commonFn pkgs;
lang = langFn pkgs;
components = componentsFn pkgs;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-vscodeext_yarnsource";
src = ../packages/vscode-ext;
packageJson = ../packages/vscode-ext/package.json;
yarnLock = ../yarn.lock;
packageResolutions."@quri/squiggle-lang" = lang.build;
packageResolutions."@quri/squiggle-components" = components.build;
};
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-vscode-lint";
buildInputs = common.buildInputs ++ common.prettier;
src =
../packages/vscode-ext; # yarn-source + "/libexec/vscode-squiggle/deps/vscode-squiggle";
buildPhase = "prettier --check .";
installPhase = "mkdir -p $out";
};
}

30
nix/squiggle-website.nix Normal file
View File

@ -0,0 +1,30 @@
{ pkgs, commonFn, langFn, componentsFn }:
rec {
common = commonFn pkgs;
lang = langFn pkgs;
components = componentsFn pkgs;
websitePackageJson = let
raw = pkgs.lib.importJSON ../packages/website/package.json;
modified = pkgs.lib.recursiveUpdate raw {
dependencies.postcss-import = "^14.1.0";
dependencies.tailwindcss = "^3.1.8";
};
packageJsonString = builtins.toJSON modified;
in pkgs.writeText "packages/website/patched-package.json" packageJsonString;
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-website_yarnsource";
src = ../packages/website;
packageJSON = websitePackageJson;
yarnLock = ../yarn.lock;
packageResolutions."@quri/squiggle-lang" = lang.build;
packageResolutions."@quri/squiggle-components" = components.build;
};
lint = pkgs.stdenv.mkDerivation {
name = "squiggle-website-lint";
buildInputs = common.buildInputs ++ common.prettier;
src = ../packages/website;
buildPhase = "yarn lint";
installPhase = "mkdir -p $out";
};
}

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# This script is only relevant if you're rolling nixos.
# Esy (a bisect_ppx dependency/build tool) is borked on nixos without using an FHS shell. https://github.com/esy/esy/issues/858
# We need to patchelf rescript executables. https://github.com/NixOS/nixpkgs/issues/107375
set -x
fhsShellName="squiggle-development"
fhsShellDotNix="{pkgs ? import <nixpkgs> {} }: (pkgs.buildFHSUserEnv { name = \"${fhsShellName}\"; targetPkgs = pkgs: [pkgs.yarn]; runScript = \"yarn\"; }).env"
nix-shell - <<<"$fhsShellDotNix"
theLd=$(patchelf --print-interpreter $(which mkdir))
patchelf --set-interpreter $theLd ./node_modules/gentype/gentype.exe
patchelf --set-interpreter $theLd ./node_modules/rescript/linux/*.exe
patchelf --set-interpreter $theLd ./node_modules/bisect_ppx/ppx
patchelf --set-interpreter $theLd ./node_moduels/bisect_ppx/bisect-ppx-report
theSo=$(find /nix/store/*$fhsShellName*/lib64 -name libstdc++.so.6 | grep $fhsShellName | head -n 1)
patchelf --replace-needed libstdc++.so.6 $theSo ./node_modules/rescript/linux/ninja.exe

View File

@ -2,12 +2,11 @@
"private": true, "private": true,
"name": "squiggle", "name": "squiggle",
"scripts": { "scripts": {
"nodeclean": "rm -r node_modules && rm -r packages/*/node_modules", "nodeclean": "rm -r node_modules && rm -r packages/*/node_modules"
"format:all": "prettier --write . && cd packages/squiggle-lang && yarn format",
"lint:all": "prettier --check . && cd packages/squiggle-lang && yarn lint:rescript"
}, },
"devDependencies": { "devDependencies": {
"prettier": "^2.7.1" "prettier": "^2.7.1",
"turbo": "^1.5.5"
}, },
"workspaces": [ "workspaces": [
"packages/*" "packages/*"

View File

@ -20,3 +20,30 @@ Runs compilation in the current directory and all of its subdirectories.
### `npx squiggle-cli-experimental watch` ### `npx squiggle-cli-experimental watch`
Watches `.squiggleU` files in the current directory (and subdirectories) and rebuilds them when they are saved. Note that this will _not_ rebuild files when their dependencies are changed, just when they are changed directly. Watches `.squiggleU` files in the current directory (and subdirectories) and rebuilds them when they are saved. Note that this will _not_ rebuild files when their dependencies are changed, just when they are changed directly.
## Further instructions
The above requires having node, npm and npx. To install the first two, see [here](https://nodejs.org/en/), to install npx, run:
```
npm install -g npx
```
Alternatively, you can run the following without the need for npx:
```
npm install squiggle-cli-experimental
node node_modules/squiggle-cli-experimental/index.js compile
```
or you can add a script to your `package.json`, like:
```
...
scripts: {
"compile": "squiggle-cli-experimental compile"
}
...
```
This can be run with `npm run compile`. `npm` knows how to reach into the node_modules directly, so it's not necessary to specify that.

View File

@ -7,13 +7,15 @@
"bin": "index.js", "bin": "index.js",
"type": "module", "type": "module",
"scripts": { "scripts": {
"start": "node ." "start": "node .",
"lint": "prettier --check .",
"format": "prettier --write ."
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"chalk": "^5.0.1", "chalk": "^5.1.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"commander": "^9.4.0", "commander": "^9.4.1",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"glob": "^8.0.3", "glob": "^8.0.3",
"indent-string": "^5.0.0" "indent-string": "^5.0.0"

View File

@ -0,0 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
setupFilesAfterEnv: ["<rootDir>/test/setup.js"],
testEnvironment: "jsdom",
};

View File

@ -1,8 +0,0 @@
[build]
base = "packages/components/"
command = "cd ../squiggle-lang && yarn build && cd ../components && yarn build"
publish = "storybook-static/"
ignore = "node -e 'process.exitCode = process.env.BRANCH.includes(\"dependabot\") ? 0 : 1' && git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../squiggle-lang"
[build.environment]
NETLIFY_USE_YARN = "true"

View File

@ -1,64 +1,73 @@
{ {
"name": "@quri/squiggle-components", "name": "@quri/squiggle-components",
"version": "0.3.1", "version": "0.5.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@floating-ui/react-dom": "^1.0.0", "@floating-ui/react-dom": "^1.0.0",
"@floating-ui/react-dom-interactions": "^0.9.1", "@floating-ui/react-dom-interactions": "^0.10.1",
"@headlessui/react": "^1.6.6", "@headlessui/react": "^1.7.3",
"@heroicons/react": "^1.0.6", "@heroicons/react": "^1.0.6",
"@hookform/resolvers": "^2.9.7", "@hookform/resolvers": "^2.9.8",
"@quri/squiggle-lang": "^0.3.0", "@quri/squiggle-lang": "^0.5.0",
"@react-hook/size": "^2.1.2", "@react-hook/size": "^2.1.2",
"@types/uuid": "^8.3.4",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"framer-motion": "^7.0.0", "framer-motion": "^7.5.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"react": "^18.1.0", "react": "^18.1.0",
"react-ace": "^10.1.0", "react-ace": "^10.1.0",
"react-hook-form": "^7.34.0", "react-hook-form": "^7.37.0",
"react-use": "^17.4.0", "react-use": "^17.4.0",
"react-vega": "^7.6.0", "react-vega": "^7.6.0",
"uuid": "^9.0.0",
"vega": "^5.22.1", "vega": "^5.22.1",
"vega-embed": "^6.21.0", "vega-embed": "^6.21.0",
"vega-lite": "^5.4.0", "vega-lite": "^5.5.0",
"vscode-uri": "^3.0.3", "vscode-uri": "^3.0.6",
"yup": "^0.32.11" "yup": "^0.32.11"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.18.6", "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
"@storybook/addon-actions": "^6.5.9", "@storybook/addon-actions": "^6.5.12",
"@storybook/addon-essentials": "^6.5.10", "@storybook/addon-essentials": "^6.5.12",
"@storybook/addon-links": "^6.5.10", "@storybook/addon-links": "^6.5.12",
"@storybook/builder-webpack5": "^6.5.10", "@storybook/builder-webpack5": "^6.5.12",
"@storybook/manager-webpack5": "^6.5.10", "@storybook/manager-webpack5": "^6.5.12",
"@storybook/node-logger": "^6.5.9", "@storybook/node-logger": "^6.5.9",
"@storybook/preset-create-react-app": "^4.1.2", "@storybook/preset-create-react-app": "^4.1.2",
"@storybook/react": "^6.5.10", "@storybook/react": "^6.5.12",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.2", "@testing-library/user-event": "^14.4.3",
"@types/jest": "^27.5.0", "@types/jest": "^27.5.0",
"@types/lodash": "^4.14.182", "@types/lodash": "^4.14.186",
"@types/node": "^18.6.4", "@types/node": "^18.8.3",
"@types/react": "^18.0.9", "@types/react": "^18.0.21",
"@types/styled-components": "^5.1.24", "@types/styled-components": "^5.1.26",
"@types/uuid": "^8.3.4",
"@types/webpack": "^5.28.0", "@types/webpack": "^5.28.0",
"canvas": "^2.10.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.1.2",
"jsdom": "^20.0.1",
"mini-css-extract-plugin": "^2.6.1", "mini-css-extract-plugin": "^2.6.1",
"postcss-cli": "^10.0.0", "postcss-cli": "^10.0.0",
"postcss-import": "^14.1.0", "postcss-import": "^15.0.0",
"postcss-loader": "^7.0.1", "postcss-loader": "^7.0.1",
"postcss-nesting": "^10.2.0",
"react": "^18.1.0", "react": "^18.1.0",
"react-scripts": "^5.0.1", "react-scripts": "^5.0.1",
"style-loader": "^3.3.1", "style-loader": "^3.3.1",
"tailwindcss": "^3.1.8", "tailwindcss": "^3.1.8",
"ts-loader": "^9.3.0", "ts-jest": "^29.0.3",
"ts-loader": "^9.4.1",
"tsconfig-paths-webpack-plugin": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0",
"typescript": "^4.7.4", "typescript": "^4.8.4",
"web-vitals": "^2.1.4", "web-vitals": "^3.0.3",
"webpack": "^5.74.0", "webpack": "^5.74.0",
"webpack-cli": "^4.10.0", "webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.3" "webpack-dev-server": "^4.11.1"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^16.8.0 || ^17 || ^18", "react": "^16.8.0 || ^17 || ^18",
@ -66,7 +75,7 @@
}, },
"scripts": { "scripts": {
"start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public", "start": "cross-env REACT_APP_FAST_REFRESH=false && start-storybook -p 6006 -s public",
"build:cjs": "tsc -b", "build:cjs": "rm -rf dist/src && rm -f dist/tsconfig.tsbuildinfo && tsc -b",
"build:css": "postcss ./src/styles/main.css -o ./dist/main.css", "build:css": "postcss ./src/styles/main.css -o ./dist/main.css",
"build:storybook": "build-storybook -s public", "build:storybook": "build-storybook -s public",
"build": "yarn run build:cjs && yarn run build:css && yarn run build:storybook", "build": "yarn run build:cjs && yarn run build:css && yarn run build:storybook",
@ -74,7 +83,10 @@
"all": "yarn bundle && yarn build", "all": "yarn bundle && yarn build",
"lint": "prettier --check .", "lint": "prettier --check .",
"format": "prettier --write .", "format": "prettier --write .",
"prepack": "yarn bundle && tsc -b" "prepack": "yarn run build:cjs && yarn run bundle",
"test": "jest",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
"test:profile": "node --cpu-prof node_modules/.bin/jest --runInBand"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [

View File

@ -24,13 +24,13 @@ export const Alert: React.FC<{
children, children,
}) => { }) => {
return ( return (
<div className={clsx("rounded-md p-4", backgroundColor)}> <div className={clsx("rounded-md p-4", backgroundColor)} role="status">
<div className="flex"> <div className="flex">
<Icon <Icon
className={clsx("h-5 w-5 flex-shrink-0", iconColor)} className={clsx("h-5 w-5 flex-shrink-0", iconColor)}
aria-hidden="true" aria-hidden="true"
/> />
<div className="ml-3"> <div className="ml-3 grow">
<header className={clsx("text-sm font-medium", headingColor)}> <header className={clsx("text-sm font-medium", headingColor)}>
{heading} {heading}
</header> </header>

View File

@ -5,6 +5,8 @@ import AceEditor from "react-ace";
import "ace-builds/src-noconflict/mode-golang"; import "ace-builds/src-noconflict/mode-golang";
import "ace-builds/src-noconflict/theme-github"; import "ace-builds/src-noconflict/theme-github";
import { SqLocation } from "@quri/squiggle-lang";
interface CodeEditorProps { interface CodeEditorProps {
value: string; value: string;
onChange: (value: string) => void; onChange: (value: string) => void;
@ -13,15 +15,17 @@ interface CodeEditorProps {
width?: number; width?: number;
height: number; height: number;
showGutter?: boolean; showGutter?: boolean;
errorLocations?: SqLocation[];
} }
export const CodeEditor: FC<CodeEditorProps> = ({ export const CodeEditor: FC<CodeEditorProps> = ({
value, value,
onChange, onChange,
onSubmit, onSubmit,
height,
oneLine = false, oneLine = false,
showGutter = false, showGutter = false,
height, errorLocations = [],
}) => { }) => {
const lineCount = value.split("\n").length; const lineCount = value.split("\n").length;
const id = useMemo(() => _.uniqueId(), []); const id = useMemo(() => _.uniqueId(), []);
@ -30,8 +34,11 @@ export const CodeEditor: FC<CodeEditorProps> = ({
const onSubmitRef = useRef<typeof onSubmit | null>(null); const onSubmitRef = useRef<typeof onSubmit | null>(null);
onSubmitRef.current = onSubmit; onSubmitRef.current = onSubmit;
const editorEl = useRef<AceEditor | null>(null);
return ( return (
<AceEditor <AceEditor
ref={editorEl}
value={value} value={value}
mode="golang" mode="golang"
theme="github" theme="github"
@ -48,10 +55,7 @@ export const CodeEditor: FC<CodeEditorProps> = ({
editorProps={{ editorProps={{
$blockScrolling: true, $blockScrolling: true,
}} }}
setOptions={{ setOptions={{}}
enableBasicAutocompletion: false,
enableLiveAutocompletion: false,
}}
commands={[ commands={[
{ {
name: "submit", name: "submit",
@ -59,6 +63,14 @@ export const CodeEditor: FC<CodeEditorProps> = ({
exec: () => onSubmitRef.current?.(), exec: () => onSubmitRef.current?.(),
}, },
]} ]}
markers={errorLocations?.map((location) => ({
startRow: location.start.line - 1,
startCol: location.start.column - 1,
endRow: location.end.line - 1,
endCol: location.end.column - 1,
className: "ace-error-marker",
type: "text",
}))}
/> />
); );
}; };

View File

@ -1,9 +1,12 @@
import * as React from "react"; import * as React from "react";
import { import {
Distribution, SqDistribution,
result, result,
distributionError, SqDistributionError,
distributionErrorToString, resultMap,
SqRecord,
environment,
SqDistributionTag,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { Vega } from "react-vega"; import { Vega } from "react-vega";
import { ErrorAlert } from "./Alert"; import { ErrorAlert } from "./Alert";
@ -14,6 +17,8 @@ import {
DistributionChartSpecOptions, DistributionChartSpecOptions,
} from "../lib/distributionSpecBuilder"; } from "../lib/distributionSpecBuilder";
import { NumberShower } from "./NumberShower"; import { NumberShower } from "./NumberShower";
import { Plot, parsePlot } from "../lib/plotParser";
import { flattenResult } from "../lib/utility";
import { hasMassBelowZero } from "../lib/distributionUtils"; import { hasMassBelowZero } from "../lib/distributionUtils";
export type DistributionPlottingSettings = { export type DistributionPlottingSettings = {
@ -23,33 +28,79 @@ export type DistributionPlottingSettings = {
} & DistributionChartSpecOptions; } & DistributionChartSpecOptions;
export type DistributionChartProps = { export type DistributionChartProps = {
distribution: Distribution; plot: Plot;
environment: environment;
width?: number; width?: number;
height: number; height: number;
xAxisType?: "number" | "dateTime";
} & DistributionPlottingSettings; } & DistributionPlottingSettings;
export function defaultPlot(distribution: SqDistribution): Plot {
return { distributions: [{ name: "default", distribution }] };
}
export function makePlot(record: SqRecord): Plot | void {
const plotResult = parsePlot(record);
if (plotResult.tag === "Ok") {
return plotResult.value;
}
}
export const DistributionChart: React.FC<DistributionChartProps> = (props) => { export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
const { const {
distribution, plot,
environment,
height, height,
showSummary, showSummary,
width, width,
logX, logX,
actions = false, actions = false,
} = props; } = props;
const shape = distribution.pointSet();
const [sized] = useSize((size) => { const [sized] = useSize((size) => {
if (shape.tag === "Error") { const shapes = flattenResult(
plot.distributions.map((x) =>
resultMap(x.distribution.pointSet(environment), (pointSet) => ({
name: x.name,
// color: x.color, // not supported yet
...pointSet.asShape(),
}))
)
);
if (shapes.tag === "Error") {
return ( return (
<ErrorAlert heading="Distribution Error"> <ErrorAlert heading="Distribution Error">
{distributionErrorToString(shape.value)} {shapes.value.toString()}
</ErrorAlert> </ErrorAlert>
); );
} }
const spec = buildVegaSpec(props); // if this is a sample set, include the samples
const samples: number[] = [];
for (const { distribution } of plot?.distributions) {
if (distribution.tag === SqDistributionTag.SampleSet) {
samples.push(...distribution.value());
}
}
let widthProp = width ? width : size.width; const domain = shapes.value.flatMap((shape) =>
shape.discrete.concat(shape.continuous)
);
const spec = buildVegaSpec({
...props,
minX: props.minX ?? Math.min(...domain.map((x) => x.x)),
maxX: props.minX ?? Math.max(...domain.map((x) => x.x)),
maxY: Math.max(...domain.map((x) => x.y)),
});
// I think size.width is sometimes not finite due to the component not being in a visible context
// This occurs during testing
let widthProp = width
? width
: Number.isFinite(size.width)
? size.width
: 400;
if (widthProp < 20) { if (widthProp < 20) {
console.warn( console.warn(
`Width of Distribution is set to ${widthProp}, which is too small` `Width of Distribution is set to ${widthProp}, which is too small`
@ -57,23 +108,30 @@ export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
widthProp = 20; widthProp = 20;
} }
const vegaData = { data: shapes.value, samples };
return ( return (
<div style={{ width: widthProp }}> <div style={{ width: widthProp }}>
{logX && hasMassBelowZero(shape.value) ? ( {logX && shapes.value.some(hasMassBelowZero) ? (
<ErrorAlert heading="Log Domain Error"> <ErrorAlert heading="Log Domain Error">
Cannot graph distribution with negative values on logarithmic scale. Cannot graph distribution with negative values on logarithmic scale.
</ErrorAlert> </ErrorAlert>
) : ( ) : (
<Vega <Vega
spec={spec} spec={spec}
data={{ con: shape.value.continuous, dis: shape.value.discrete }} data={vegaData}
width={widthProp - 10} width={widthProp - 10}
height={height} height={height}
actions={actions} actions={actions}
/> />
)} )}
<div className="flex justify-center"> <div className="flex justify-center">
{showSummary && <SummaryTable distribution={distribution} />} {showSummary && plot.distributions.length === 1 && (
<SummaryTable
distribution={plot.distributions[0].distribution}
environment={environment}
/>
)}
</div> </div>
</div> </div>
); );
@ -96,32 +154,36 @@ const Cell: React.FC<{ children: React.ReactNode }> = ({ children }) => (
); );
type SummaryTableProps = { type SummaryTableProps = {
distribution: Distribution; distribution: SqDistribution;
environment: environment;
}; };
const SummaryTable: React.FC<SummaryTableProps> = ({ distribution }) => { const SummaryTable: React.FC<SummaryTableProps> = ({
const mean = distribution.mean(); distribution,
const stdev = distribution.stdev(); environment,
const p5 = distribution.inv(0.05); }) => {
const p10 = distribution.inv(0.1); const mean = distribution.mean(environment);
const p25 = distribution.inv(0.25); const stdev = distribution.stdev(environment);
const p50 = distribution.inv(0.5); const p5 = distribution.inv(environment, 0.05);
const p75 = distribution.inv(0.75); const p10 = distribution.inv(environment, 0.1);
const p90 = distribution.inv(0.9); const p25 = distribution.inv(environment, 0.25);
const p95 = distribution.inv(0.95); const p50 = distribution.inv(environment, 0.5);
const p75 = distribution.inv(environment, 0.75);
const p90 = distribution.inv(environment, 0.9);
const p95 = distribution.inv(environment, 0.95);
const hasResult = (x: result<number, distributionError>): boolean => const hasResult = (x: result<number, SqDistributionError>): boolean =>
x.tag === "Ok"; x.tag === "Ok";
const unwrapResult = ( const unwrapResult = (
x: result<number, distributionError> x: result<number, SqDistributionError>
): React.ReactNode => { ): React.ReactNode => {
if (x.tag === "Ok") { if (x.tag === "Ok") {
return <NumberShower number={x.value} />; return <NumberShower number={x.value} />;
} else { } else {
return ( return (
<ErrorAlert heading="Distribution Error"> <ErrorAlert heading="Distribution Error">
{distributionErrorToString(x.value)} {x.value.toString()}
</ErrorAlert> </ErrorAlert>
); );
} }

View File

@ -1,14 +1,15 @@
import * as React from "react"; import * as React from "react";
import { import {
lambdaValue, SqLambda,
environment, environment,
runForeign, SqValueTag,
errorValueToString, SqError,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { FunctionChart1Dist } from "./FunctionChart1Dist"; import { FunctionChart1Dist } from "./FunctionChart1Dist";
import { FunctionChart1Number } from "./FunctionChart1Number"; import { FunctionChart1Number } from "./FunctionChart1Number";
import { DistributionPlottingSettings } from "./DistributionChart"; import { DistributionPlottingSettings } from "./DistributionChart";
import { ErrorAlert, MessageAlert } from "./Alert"; import { MessageAlert } from "./Alert";
import { SquiggleErrorAlert } from "./SquiggleErrorAlert";
export type FunctionChartSettings = { export type FunctionChartSettings = {
start: number; start: number;
@ -17,13 +18,32 @@ export type FunctionChartSettings = {
}; };
interface FunctionChartProps { interface FunctionChartProps {
fn: lambdaValue; fn: SqLambda;
chartSettings: FunctionChartSettings; chartSettings: FunctionChartSettings;
distributionPlotSettings: DistributionPlottingSettings; distributionPlotSettings: DistributionPlottingSettings;
environment: environment; environment: environment;
height: number; height: number;
} }
const FunctionCallErrorAlert = ({ error }: { error: SqError }) => {
const [expanded, setExpanded] = React.useState(false);
if (expanded) {
}
return (
<MessageAlert heading="Function Display Failed">
<div className="space-y-2">
<span
className="underline decoration-dashed cursor-pointer"
onClick={() => setExpanded(!expanded)}
>
{expanded ? "Hide" : "Show"} error details
</span>
{expanded ? <SquiggleErrorAlert error={error} /> : null}
</div>
</MessageAlert>
);
};
export const FunctionChart: React.FC<FunctionChartProps> = ({ export const FunctionChart: React.FC<FunctionChartProps> = ({
fn, fn,
chartSettings, chartSettings,
@ -31,15 +51,16 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
distributionPlotSettings, distributionPlotSettings,
height, height,
}) => { }) => {
if (fn.parameters.length > 1) { console.log(fn.parameters().length);
if (fn.parameters().length !== 1) {
return ( return (
<MessageAlert heading="Function Display Not Supported"> <MessageAlert heading="Function Display Not Supported">
Only functions with one parameter are displayed. Only functions with one parameter are displayed.
</MessageAlert> </MessageAlert>
); );
} }
const result1 = runForeign(fn, [chartSettings.start], environment); const result1 = fn.call([chartSettings.start]);
const result2 = runForeign(fn, [chartSettings.stop], environment); const result2 = fn.call([chartSettings.stop]);
const getValidResult = () => { const getValidResult = () => {
if (result1.tag === "Ok") { if (result1.tag === "Ok") {
return result1; return result1;
@ -52,15 +73,11 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
const validResult = getValidResult(); const validResult = getValidResult();
if (validResult.tag === "Error") { if (validResult.tag === "Error") {
return ( return <FunctionCallErrorAlert error={validResult.value} />;
<ErrorAlert heading="Error">
{errorValueToString(validResult.value)}
</ErrorAlert>
);
} }
switch (validResult.value.tag) { switch (validResult.value.tag) {
case "distribution": case SqValueTag.Distribution:
return ( return (
<FunctionChart1Dist <FunctionChart1Dist
fn={fn} fn={fn}
@ -70,7 +87,7 @@ export const FunctionChart: React.FC<FunctionChartProps> = ({
distributionPlotSettings={distributionPlotSettings} distributionPlotSettings={distributionPlotSettings}
/> />
); );
case "number": case SqValueTag.Number:
return ( return (
<FunctionChart1Number <FunctionChart1Number
fn={fn} fn={fn}

View File

@ -2,20 +2,20 @@ import * as React from "react";
import _ from "lodash"; import _ from "lodash";
import type { Spec } from "vega"; import type { Spec } from "vega";
import { import {
Distribution, SqDistribution,
result, result,
lambdaValue, SqLambda,
environment, environment,
runForeign, SqError,
squiggleExpression, SqValue,
errorValue, SqValueTag,
errorValueToString,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega"; import { createClassFromSpec } from "react-vega";
import * as percentilesSpec from "../vega-specs/spec-percentiles.json"; import * as percentilesSpec from "../vega-specs/spec-percentiles.json";
import { import {
DistributionChart, DistributionChart,
DistributionPlottingSettings, DistributionPlottingSettings,
defaultPlot,
} from "./DistributionChart"; } from "./DistributionChart";
import { NumberShower } from "./NumberShower"; import { NumberShower } from "./NumberShower";
import { ErrorAlert } from "./Alert"; import { ErrorAlert } from "./Alert";
@ -45,7 +45,7 @@ export type FunctionChartSettings = {
}; };
interface FunctionChart1DistProps { interface FunctionChart1DistProps {
fn: lambdaValue; fn: SqLambda;
chartSettings: FunctionChartSettings; chartSettings: FunctionChartSettings;
distributionPlotSettings: DistributionPlottingSettings; distributionPlotSettings: DistributionPlottingSettings;
environment: environment; environment: environment;
@ -76,9 +76,17 @@ type errors = _.Dictionary<
}[] }[]
>; >;
type point = { x: number; value: result<Distribution, string> }; type point = { x: number; value: result<SqDistribution, string> };
let getPercentiles = ({ chartSettings, fn, environment }) => { let getPercentiles = ({
chartSettings,
fn,
environment,
}: {
chartSettings: FunctionChartSettings;
fn: SqLambda;
environment: environment;
}) => {
let chartPointsToRender = _rangeByCount( let chartPointsToRender = _rangeByCount(
chartSettings.start, chartSettings.start,
chartSettings.stop, chartSettings.stop,
@ -86,9 +94,9 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
); );
let chartPointsData: point[] = chartPointsToRender.map((x) => { let chartPointsData: point[] = chartPointsToRender.map((x) => {
let result = runForeign(fn, [x], environment); let result = fn.call([x]);
if (result.tag === "Ok") { if (result.tag === "Ok") {
if (result.value.tag === "distribution") { if (result.value.tag === SqValueTag.Distribution) {
return { x, value: { tag: "Ok", value: result.value.value } }; return { x, value: { tag: "Ok", value: result.value.value } };
} else { } else {
return { return {
@ -103,13 +111,13 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
} else { } else {
return { return {
x, x,
value: { tag: "Error", value: errorValueToString(result.value) }, value: { tag: "Error", value: result.value.toString() },
}; };
} }
}); });
let initialPartition: [ let initialPartition: [
{ x: number; value: Distribution }[], { x: number; value: SqDistribution }[],
{ x: number; value: string }[] { x: number; value: string }[]
] = [[], []]; ] = [[], []];
@ -125,26 +133,23 @@ let getPercentiles = ({ chartSettings, fn, environment }) => {
let groupedErrors: errors = _.groupBy(errors, (x) => x.value); let groupedErrors: errors = _.groupBy(errors, (x) => x.value);
let percentiles: percentiles = functionImage.map(({ x, value }) => { let percentiles: percentiles = functionImage.map(({ x, value }) => {
// We convert it to to a pointSet distribution first, so that in case its a sample set const res = {
// distribution, it doesn't internally convert it to a pointSet distribution for every
// single inv() call.
let toPointSet: Distribution = unwrap(value.toPointSet());
return {
x: x, x: x,
p1: unwrap(toPointSet.inv(0.01)), p1: unwrap(value.inv(environment, 0.01)),
p5: unwrap(toPointSet.inv(0.05)), p5: unwrap(value.inv(environment, 0.05)),
p10: unwrap(toPointSet.inv(0.1)), p10: unwrap(value.inv(environment, 0.1)),
p20: unwrap(toPointSet.inv(0.2)), p20: unwrap(value.inv(environment, 0.2)),
p30: unwrap(toPointSet.inv(0.3)), p30: unwrap(value.inv(environment, 0.3)),
p40: unwrap(toPointSet.inv(0.4)), p40: unwrap(value.inv(environment, 0.4)),
p50: unwrap(toPointSet.inv(0.5)), p50: unwrap(value.inv(environment, 0.5)),
p60: unwrap(toPointSet.inv(0.6)), p60: unwrap(value.inv(environment, 0.6)),
p70: unwrap(toPointSet.inv(0.7)), p70: unwrap(value.inv(environment, 0.7)),
p80: unwrap(toPointSet.inv(0.8)), p80: unwrap(value.inv(environment, 0.8)),
p90: unwrap(toPointSet.inv(0.9)), p90: unwrap(value.inv(environment, 0.9)),
p95: unwrap(toPointSet.inv(0.95)), p95: unwrap(value.inv(environment, 0.95)),
p99: unwrap(toPointSet.inv(0.99)), p99: unwrap(value.inv(environment, 0.99)),
}; };
return res;
}); });
return { percentiles, errors: groupedErrors }; return { percentiles, errors: groupedErrors };
@ -167,19 +172,20 @@ export const FunctionChart1Dist: React.FC<FunctionChart1DistProps> = ({
const signalListeners = { mousemove: handleHover, mouseout: handleOut }; const signalListeners = { mousemove: handleHover, mouseout: handleOut };
//TODO: This custom error handling is a bit hacky and should be improved. //TODO: This custom error handling is a bit hacky and should be improved.
let mouseItem: result<squiggleExpression, errorValue> = !!mouseOverlay let mouseItem: result<SqValue, SqError> = !!mouseOverlay
? runForeign(fn, [mouseOverlay], environment) ? fn.call([mouseOverlay])
: { : {
tag: "Error", tag: "Error",
value: { value: SqError.createOtherError(
tag: "RETodo", "Hover x-coordinate returned NaN. Expected a number."
value: "Hover x-coordinate returned NaN. Expected a number.", ),
},
}; };
let showChart = let showChart =
mouseItem.tag === "Ok" && mouseItem.value.tag === "distribution" ? ( mouseItem.tag === "Ok" &&
mouseItem.value.tag === SqValueTag.Distribution ? (
<DistributionChart <DistributionChart
distribution={mouseItem.value.value} plot={defaultPlot(mouseItem.value.value)}
environment={environment}
width={400} width={400}
height={50} height={50}
{...distributionPlotSettings} {...distributionPlotSettings}

View File

@ -1,16 +1,11 @@
import * as React from "react"; import * as React from "react";
import _ from "lodash"; import _ from "lodash";
import type { Spec } from "vega"; import type { Spec } from "vega";
import { import { result, SqLambda, environment, SqValueTag } from "@quri/squiggle-lang";
result,
lambdaValue,
environment,
runForeign,
errorValueToString,
} from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega"; import { createClassFromSpec } from "react-vega";
import * as lineChartSpec from "../vega-specs/spec-line-chart.json"; import * as lineChartSpec from "../vega-specs/spec-line-chart.json";
import { ErrorAlert } from "./Alert"; import { ErrorAlert } from "./Alert";
import { squiggleValueTag } from "@quri/squiggle-lang/src/rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_tag";
let SquiggleLineChart = createClassFromSpec({ let SquiggleLineChart = createClassFromSpec({
spec: lineChartSpec as Spec, spec: lineChartSpec as Spec,
@ -30,7 +25,7 @@ export type FunctionChartSettings = {
}; };
interface FunctionChart1NumberProps { interface FunctionChart1NumberProps {
fn: lambdaValue; fn: SqLambda;
chartSettings: FunctionChartSettings; chartSettings: FunctionChartSettings;
environment: environment; environment: environment;
height: number; height: number;
@ -38,7 +33,15 @@ interface FunctionChart1NumberProps {
type point = { x: number; value: result<number, string> }; type point = { x: number; value: result<number, string> };
let getFunctionImage = ({ chartSettings, fn, environment }) => { let getFunctionImage = ({
chartSettings,
fn,
environment,
}: {
chartSettings: FunctionChartSettings;
fn: SqLambda;
environment: environment;
}) => {
let chartPointsToRender = _rangeByCount( let chartPointsToRender = _rangeByCount(
chartSettings.start, chartSettings.start,
chartSettings.stop, chartSettings.stop,
@ -46,9 +49,9 @@ let getFunctionImage = ({ chartSettings, fn, environment }) => {
); );
let chartPointsData: point[] = chartPointsToRender.map((x) => { let chartPointsData: point[] = chartPointsToRender.map((x) => {
let result = runForeign(fn, [x], environment); let result = fn.call([x]);
if (result.tag === "Ok") { if (result.tag === "Ok") {
if (result.value.tag == "number") { if (result.value.tag === SqValueTag.Number) {
return { x, value: { tag: "Ok", value: result.value.value } }; return { x, value: { tag: "Ok", value: result.value.value } };
} else { } else {
return { return {
@ -62,7 +65,7 @@ let getFunctionImage = ({ chartSettings, fn, environment }) => {
} else { } else {
return { return {
x, x,
value: { tag: "Error", value: errorValueToString(result.value) }, value: { tag: "Error", value: result.value.toString() },
}; };
} }
}); });

View File

@ -1,25 +1,22 @@
import * as React from "react"; import * as React from "react";
import { import {
squiggleExpression, SqValue,
bindings,
environment, environment,
jsImports, SqProject,
defaultImports,
defaultBindings,
defaultEnvironment, defaultEnvironment,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { useSquiggle } from "../lib/hooks"; import { useSquiggle } from "../lib/hooks";
import { SquiggleViewer } from "./SquiggleViewer"; import { SquiggleViewer } from "./SquiggleViewer";
import { JsImports } from "../lib/jsImports";
import { getValueToRender } from "../lib/utility";
export interface SquiggleChartProps { export type SquiggleChartProps = {
/** The input string for squiggle */ /** The input string for squiggle */
code?: string; code: string;
/** Allows to re-run the code if code hasn't changed */ /** Allows to re-run the code if code hasn't changed */
executionId?: number; executionId?: number;
/** If the output requires monte carlo sampling, the amount of samples */ /** If the output requires monte carlo sampling, the amount of samples */
sampleCount?: number; sampleCount?: number;
/** The amount of points returned to draw the distribution */
environment?: environment;
/** If the result is a function, where the function domain starts */ /** If the result is a function, where the function domain starts */
diagramStart?: number; diagramStart?: number;
/** If the result is a function, where the function domain ends */ /** If the result is a function, where the function domain ends */
@ -27,14 +24,12 @@ export interface SquiggleChartProps {
/** If the result is a function, the amount of stops sampled */ /** If the result is a function, the amount of stops sampled */
diagramCount?: number; diagramCount?: number;
/** When the squiggle code gets reevaluated */ /** When the squiggle code gets reevaluated */
onChange?(expr: squiggleExpression | undefined): void; onChange?(expr: SqValue | undefined, sourceName: string): void;
/** CSS width of the element */ /** CSS width of the element */
width?: number; width?: number;
height?: number; height?: number;
/** Bindings of previous variables declared */
bindings?: bindings;
/** JS imported parameters */ /** JS imported parameters */
jsImports?: jsImports; jsImports?: JsImports;
/** Whether to show a summary of the distribution */ /** Whether to show a summary of the distribution */
showSummary?: boolean; showSummary?: boolean;
/** Set the x scale to be logarithmic by deault */ /** Set the x scale to be logarithmic by deault */
@ -51,24 +46,35 @@ export interface SquiggleChartProps {
minX?: number; minX?: number;
/** Specify the upper bound of the x scale */ /** Specify the upper bound of the x scale */
maxX?: number; maxX?: number;
/** Whether the x-axis should be dates or numbers */
xAxisType?: "number" | "dateTime";
/** Whether to show vega actions to the user, so they can copy the chart spec */ /** Whether to show vega actions to the user, so they can copy the chart spec */
distributionChartActions?: boolean; distributionChartActions?: boolean;
enableLocalSettings?: boolean; enableLocalSettings?: boolean;
} } & (StandaloneExecutionProps | ProjectExecutionProps);
// Props needed for a standalone execution
type StandaloneExecutionProps = {
project?: undefined;
continues?: undefined;
/** The amount of points returned to draw the distribution, not needed if using a project */
environment?: environment;
};
// Props needed when executing inside a project.
type ProjectExecutionProps = {
environment?: undefined;
/** The project that this execution is part of */
project: SqProject;
/** What other squiggle sources from the project to continue. Default [] */
continues?: string[];
};
const defaultOnChange = () => {}; const defaultOnChange = () => {};
const defaultImports: JsImports = {};
export const SquiggleChart: React.FC<SquiggleChartProps> = React.memo( export const splitSquiggleChartSettings = (props: SquiggleChartProps) => {
({ const {
code = "",
executionId = 0,
environment,
onChange = defaultOnChange, // defaultOnChange must be constant, don't move its definition here
height = 200,
bindings = defaultBindings,
jsImports = defaultImports,
showSummary = false, showSummary = false,
width,
logX = false, logX = false,
expY = false, expY = false,
diagramStart = 0, diagramStart = 0,
@ -79,44 +85,72 @@ export const SquiggleChart: React.FC<SquiggleChartProps> = React.memo(
maxX, maxX,
color, color,
title, title,
xAxisType = "number",
distributionChartActions, distributionChartActions,
enableLocalSettings = false, } = props;
}) => {
const result = useSquiggle({ const distributionPlotSettings = {
showSummary,
logX,
expY,
format: tickFormat,
minX,
maxX,
color,
title,
xAxisType,
actions: distributionChartActions,
};
const chartSettings = {
start: diagramStart,
stop: diagramStop,
count: diagramCount,
};
return { distributionPlotSettings, chartSettings };
};
export const SquiggleChart: React.FC<SquiggleChartProps> = React.memo(
(props) => {
const { distributionPlotSettings, chartSettings } =
splitSquiggleChartSettings(props);
const {
code, code,
bindings, jsImports = defaultImports,
onChange = defaultOnChange, // defaultOnChange must be constant, don't move its definition here
executionId = 0,
width,
height = 200,
enableLocalSettings = false,
continues,
project,
environment, environment,
} = props;
const resultAndBindings = useSquiggle({
environment,
continues,
project,
code,
jsImports, jsImports,
onChange, onChange,
executionId, executionId,
}); });
const distributionPlotSettings = { const valueToRender = getValueToRender(resultAndBindings);
showSummary,
logX,
expY,
format: tickFormat,
minX,
maxX,
color,
title,
actions: distributionChartActions,
};
const chartSettings = {
start: diagramStart,
stop: diagramStop,
count: diagramCount,
};
return ( return (
<SquiggleViewer <SquiggleViewer
result={result} result={valueToRender}
width={width} width={width}
height={height} height={height}
distributionPlotSettings={distributionPlotSettings} distributionPlotSettings={distributionPlotSettings}
chartSettings={chartSettings} chartSettings={chartSettings}
environment={environment ?? defaultEnvironment} environment={
project ? project.getEnvironment() : environment ?? defaultEnvironment
}
enableLocalSettings={enableLocalSettings} enableLocalSettings={enableLocalSettings}
/> />
); );

View File

@ -1,23 +1,29 @@
import React from "react"; import React from "react";
import { CodeEditor } from "./CodeEditor"; import { CodeEditor } from "./CodeEditor";
import { environment, bindings, jsImports } from "@quri/squiggle-lang";
import { defaultImports, defaultBindings } from "@quri/squiggle-lang";
import { SquiggleContainer } from "./SquiggleContainer"; import { SquiggleContainer } from "./SquiggleContainer";
import { SquiggleChart, SquiggleChartProps } from "./SquiggleChart"; import {
import { useSquigglePartial, useMaybeControlledValue } from "../lib/hooks"; splitSquiggleChartSettings,
import { SquiggleErrorAlert } from "./SquiggleErrorAlert"; SquiggleChartProps,
} from "./SquiggleChart";
import { useMaybeControlledValue, useSquiggle } from "../lib/hooks";
import { JsImports } from "../lib/jsImports";
import { defaultEnvironment, SqLocation, SqProject } from "@quri/squiggle-lang";
import { SquiggleViewer } from "./SquiggleViewer";
import { getErrorLocations, getValueToRender } from "../lib/utility";
const WrappedCodeEditor: React.FC<{ const WrappedCodeEditor: React.FC<{
code: string; code: string;
setCode: (code: string) => void; setCode: (code: string) => void;
}> = ({ code, setCode }) => ( errorLocations?: SqLocation[];
<div className="border border-grey-200 p-2 m-4"> }> = ({ code, setCode, errorLocations }) => (
<div className="border border-grey-200 p-2 m-4" data-testid="squiggle-editor">
<CodeEditor <CodeEditor
value={code} value={code}
onChange={setCode} onChange={setCode}
oneLine={true} oneLine={true}
showGutter={false} showGutter={false}
height={20} height={20}
errorLocations={errorLocations}
/> />
</div> </div>
); );
@ -27,6 +33,9 @@ export type SquiggleEditorProps = SquiggleChartProps & {
onCodeChange?: (code: string) => void; onCodeChange?: (code: string) => void;
}; };
const defaultOnChange = () => {};
const defaultImports: JsImports = {};
export const SquiggleEditor: React.FC<SquiggleEditorProps> = (props) => { export const SquiggleEditor: React.FC<SquiggleEditorProps> = (props) => {
const [code, setCode] = useMaybeControlledValue({ const [code, setCode] = useMaybeControlledValue({
value: props.code, value: props.code,
@ -34,59 +43,50 @@ export const SquiggleEditor: React.FC<SquiggleEditorProps> = (props) => {
onChange: props.onCodeChange, onChange: props.onCodeChange,
}); });
let chartProps = { ...props, code }; const { distributionPlotSettings, chartSettings } =
return ( splitSquiggleChartSettings(props);
<SquiggleContainer>
<WrappedCodeEditor code={code} setCode={setCode} />
<SquiggleChart {...chartProps} />
</SquiggleContainer>
);
};
export interface SquigglePartialProps { const {
/** The text inside the input (controlled) */
code?: string;
/** The default text inside the input (unControlled) */
defaultCode?: string;
/** when the environment changes. Used again for notebook magic*/
onChange?(expr: bindings | undefined): void;
/** When the code changes */
onCodeChange?(code: string): void;
/** Previously declared variables */
bindings?: bindings;
/** If the output requires monte carlo sampling, the amount of samples */
environment?: environment;
/** Variables imported from js */
jsImports?: jsImports;
}
export const SquigglePartial: React.FC<SquigglePartialProps> = ({
code: controlledCode,
defaultCode = "",
onChange,
onCodeChange,
bindings = defaultBindings,
environment,
jsImports = defaultImports,
}: SquigglePartialProps) => {
const [code, setCode] = useMaybeControlledValue<string>({
value: controlledCode,
defaultValue: defaultCode,
onChange: onCodeChange,
});
const result = useSquigglePartial({
code,
bindings,
environment, environment,
jsImports = defaultImports,
onChange = defaultOnChange, // defaultOnChange must be constant, don't move its definition here
executionId = 0,
width,
height = 200,
enableLocalSettings = false,
continues,
project,
} = props;
const resultAndBindings = useSquiggle({
environment,
continues,
code,
project,
jsImports, jsImports,
onChange, onChange,
executionId,
}); });
const valueToRender = getValueToRender(resultAndBindings);
const errorLocations = getErrorLocations(resultAndBindings.result);
return ( return (
<SquiggleContainer> <SquiggleContainer>
<WrappedCodeEditor code={code} setCode={setCode} /> <WrappedCodeEditor
{result.tag !== "Ok" ? <SquiggleErrorAlert error={result.value} /> : null} code={code}
setCode={setCode}
errorLocations={errorLocations}
/>
<SquiggleViewer
result={valueToRender}
width={width}
height={height}
distributionPlotSettings={distributionPlotSettings}
chartSettings={chartSettings}
environment={environment ?? defaultEnvironment}
enableLocalSettings={enableLocalSettings}
/>
</SquiggleContainer> </SquiggleContainer>
); );
}; };

View File

@ -1,52 +0,0 @@
import React from "react";
import { SquiggleEditor } from "./SquiggleEditor";
import type { SquiggleEditorProps } from "./SquiggleEditor";
import { runPartial, defaultBindings } from "@quri/squiggle-lang";
import type {
result,
errorValue,
bindings as bindingsType,
} from "@quri/squiggle-lang";
function resultDefault(x: result<bindingsType, errorValue>): bindingsType {
switch (x.tag) {
case "Ok":
return x.value;
case "Error":
return defaultBindings;
}
}
export type SquiggleEditorWithImportedBindingsProps = SquiggleEditorProps & {
bindingsImportUrl: string;
};
export const SquiggleEditorWithImportedBindings: React.FC<
SquiggleEditorWithImportedBindingsProps
> = (props) => {
const { bindingsImportUrl, ...editorProps } = props;
const [bindingsResult, setBindingsResult] = React.useState({
tag: "Ok",
value: defaultBindings,
} as result<bindingsType, errorValue>);
React.useEffect(() => {
async function retrieveBindings(fileName: string) {
let contents = await fetch(fileName).then((response) => {
return response.text();
});
setBindingsResult(
runPartial(
contents,
editorProps.bindings,
editorProps.environment,
editorProps.jsImports
)
);
}
retrieveBindings(bindingsImportUrl);
}, [bindingsImportUrl]);
const deliveredBindings = resultDefault(bindingsResult);
return (
<SquiggleEditor {...{ ...editorProps, bindings: deliveredBindings }} />
);
};

View File

@ -1,11 +1,44 @@
import { errorValue, errorValueToString } from "@quri/squiggle-lang"; import { SqError, SqFrame } from "@quri/squiggle-lang";
import React from "react"; import React from "react";
import { ErrorAlert } from "./Alert"; import { ErrorAlert } from "./Alert";
type Props = { type Props = {
error: errorValue; error: SqError;
};
const StackTraceFrame: React.FC<{ frame: SqFrame }> = ({ frame }) => {
const location = frame.location();
return (
<div>
{frame.name()}
{location
? ` at line ${location.start.line}, column ${location.start.column}`
: ""}
</div>
);
};
const StackTrace: React.FC<Props> = ({ error }) => {
const frames = error.getFrameArray();
return frames.length ? (
<div>
<div className="font-medium">Stack trace:</div>
<div className="ml-4">
{frames.map((frame, i) => (
<StackTraceFrame frame={frame} key={i} />
))}
</div>
</div>
) : null;
}; };
export const SquiggleErrorAlert: React.FC<Props> = ({ error }) => { export const SquiggleErrorAlert: React.FC<Props> = ({ error }) => {
return <ErrorAlert heading="Error">{errorValueToString(error)}</ErrorAlert>; return (
<ErrorAlert heading="Error">
<div className="space-y-4">
<div>{error.toString()}</div>
<StackTrace error={error} />
</div>
</ErrorAlert>
);
}; };

View File

@ -8,7 +8,11 @@ import React, {
} from "react"; } from "react";
import { useForm, UseFormRegister, useWatch } from "react-hook-form"; import { useForm, UseFormRegister, useWatch } from "react-hook-form";
import * as yup from "yup"; import * as yup from "yup";
import { useMaybeControlledValue, useRunnerState } from "../lib/hooks"; import {
useMaybeControlledValue,
useRunnerState,
useSquiggle,
} from "../lib/hooks";
import { yupResolver } from "@hookform/resolvers/yup"; import { yupResolver } from "@hookform/resolvers/yup";
import { import {
ChartSquareBarIcon, ChartSquareBarIcon,
@ -24,9 +28,9 @@ import {
} from "@heroicons/react/solid"; } from "@heroicons/react/solid";
import clsx from "clsx"; import clsx from "clsx";
import { defaultBindings, environment } from "@quri/squiggle-lang"; import { environment, SqProject } from "@quri/squiggle-lang";
import { SquiggleChart, SquiggleChartProps } from "./SquiggleChart"; import { SquiggleChartProps } from "./SquiggleChart";
import { CodeEditor } from "./CodeEditor"; import { CodeEditor } from "./CodeEditor";
import { JsonEditor } from "./JsonEditor"; import { JsonEditor } from "./JsonEditor";
import { ErrorAlert, SuccessAlert } from "./Alert"; import { ErrorAlert, SuccessAlert } from "./Alert";
@ -37,11 +41,11 @@ import { InputItem } from "./ui/InputItem";
import { Text } from "./ui/Text"; import { Text } from "./ui/Text";
import { ViewSettings, viewSettingsSchema } from "./ViewSettings"; import { ViewSettings, viewSettingsSchema } from "./ViewSettings";
import { HeadedSection } from "./ui/HeadedSection"; import { HeadedSection } from "./ui/HeadedSection";
import { import { defaultTickFormat } from "../lib/distributionSpecBuilder";
defaultColor,
defaultTickFormat,
} from "../lib/distributionSpecBuilder";
import { Button } from "./ui/Button"; import { Button } from "./ui/Button";
import { JsImports } from "../lib/jsImports";
import { getErrorLocations, getValueToRender } from "../lib/utility";
import { SquiggleViewer } from "./SquiggleViewer";
type PlaygroundProps = SquiggleChartProps & { type PlaygroundProps = SquiggleChartProps & {
/** The initial squiggle string to put in the playground */ /** The initial squiggle string to put in the playground */
@ -115,8 +119,8 @@ const SamplingSettings: React.FC<{ register: UseFormRegister<FormFields> }> = ({
); );
const InputVariablesSettings: React.FC<{ const InputVariablesSettings: React.FC<{
initialImports: any; // TODO - any json type initialImports: JsImports;
setImports: (imports: any) => void; setImports: (imports: JsImports) => void;
}> = ({ initialImports, setImports }) => { }> = ({ initialImports, setImports }) => {
const [importString, setImportString] = useState(() => const [importString, setImportString] = useState(() =>
JSON.stringify(initialImports) JSON.stringify(initialImports)
@ -125,7 +129,7 @@ const InputVariablesSettings: React.FC<{
const onChange = (value: string) => { const onChange = (value: string) => {
setImportString(value); setImportString(value);
let imports = {} as any; let imports = {};
try { try {
imports = JSON.parse(value); imports = JSON.parse(value);
setImportsAreValid(true); setImportsAreValid(true);
@ -178,7 +182,7 @@ const RunControls: React.FC<{
const CurrentPlayIcon = isRunning ? RefreshIcon : PlayIcon; const CurrentPlayIcon = isRunning ? RefreshIcon : PlayIcon;
return ( return (
<div className="flex space-x-1 items-center"> <div className="flex space-x-1 items-center" data-testid="autorun-controls">
{autorunMode ? null : ( {autorunMode ? null : (
<button onClick={run}> <button onClick={run}>
<CurrentPlayIcon <CurrentPlayIcon
@ -234,13 +238,12 @@ export const PlaygroundContext = React.createContext<PlaygroundContextShape>({
export const SquigglePlayground: FC<PlaygroundProps> = ({ export const SquigglePlayground: FC<PlaygroundProps> = ({
defaultCode = "", defaultCode = "",
height = 500, height = 500,
showSummary = false, showSummary = true,
logX = false, logX = false,
expY = false, expY = false,
title, title,
minX, minX,
maxX, maxX,
color = defaultColor,
tickFormat = defaultTickFormat, tickFormat = defaultTickFormat,
distributionChartActions, distributionChartActions,
code: controlledCode, code: controlledCode,
@ -248,6 +251,8 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
onSettingsChange, onSettingsChange,
showEditor = true, showEditor = true,
showShareButton = false, showShareButton = false,
continues,
project,
}) => { }) => {
const [code, setCode] = useMaybeControlledValue({ const [code, setCode] = useMaybeControlledValue({
value: controlledCode, value: controlledCode,
@ -255,7 +260,7 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
onChange: onCodeChange, onChange: onCodeChange,
}); });
const [imports, setImports] = useState({}); const [imports, setImports] = useState<JsImports>({});
const { register, control } = useForm({ const { register, control } = useForm({
resolver: yupResolver(schema), resolver: yupResolver(schema),
@ -268,7 +273,6 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
title, title,
minX, minX,
maxX, maxX,
color,
tickFormat, tickFormat,
distributionChartActions, distributionChartActions,
showSummary, showSummary,
@ -286,7 +290,7 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
onSettingsChange?.(vars); onSettingsChange?.(vars);
}, [vars, onSettingsChange]); }, [vars, onSettingsChange]);
const env: environment = useMemo( const environment: environment = useMemo(
() => ({ () => ({
sampleCount: Number(vars.sampleCount), sampleCount: Number(vars.sampleCount),
xyPointLength: Number(vars.xyPointLength), xyPointLength: Number(vars.xyPointLength),
@ -303,27 +307,53 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
executionId, executionId,
} = useRunnerState(code); } = useRunnerState(code);
const resultAndBindings = useSquiggle({
environment,
continues,
code: renderedCode,
project,
jsImports: imports,
executionId,
});
const valueToRender = getValueToRender(resultAndBindings);
const squiggleChart = const squiggleChart =
renderedCode === "" ? null : ( renderedCode === "" ? null : (
<div className="relative"> <div className="relative">
{isRunning ? ( {isRunning ? (
<div className="absolute inset-0 bg-white opacity-0 animate-semi-appear" /> <div className="absolute inset-0 bg-white opacity-0 animate-semi-appear" />
) : null} ) : null}
<SquiggleChart <SquiggleViewer
code={renderedCode} result={valueToRender}
executionId={executionId} environment={environment}
environment={env} height={vars.chartHeight || 150}
{...vars} distributionPlotSettings={{
bindings={defaultBindings} showSummary: vars.showSummary ?? false,
jsImports={imports} logX: vars.logX ?? false,
expY: vars.expY ?? false,
format: vars.tickFormat,
minX: vars.minX,
maxX: vars.maxX,
title: vars.title,
actions: vars.distributionChartActions,
}}
chartSettings={{
start: vars.diagramStart ?? 0,
stop: vars.diagramStop ?? 10,
count: vars.diagramCount ?? 20,
}}
enableLocalSettings={true} enableLocalSettings={true}
/> />
</div> </div>
); );
const errorLocations = getErrorLocations(resultAndBindings.result);
const firstTab = vars.showEditor ? ( const firstTab = vars.showEditor ? (
<div className="border border-slate-200"> <div className="border border-slate-200" data-testid="squiggle-editor">
<CodeEditor <CodeEditor
errorLocations={errorLocations}
value={code} value={code}
onChange={setCode} onChange={setCode}
onSubmit={run} onSubmit={run}
@ -373,7 +403,9 @@ export const SquigglePlayground: FC<PlaygroundProps> = ({
> >
{tabs} {tabs}
</div> </div>
<div className="w-1/2 p-2 pl-4">{squiggleChart}</div> <div className="w-1/2 p-2 pl-4" data-testid="playground-result">
{squiggleChart}
</div>
</div> </div>
); );

View File

@ -1,14 +1,17 @@
import React from "react"; import React, { useContext } from "react";
import { squiggleExpression, declaration } from "@quri/squiggle-lang"; import { SqDistributionTag, SqValue, SqValueTag } from "@quri/squiggle-lang";
import { NumberShower } from "../NumberShower"; import { NumberShower } from "../NumberShower";
import { DistributionChart } from "../DistributionChart"; import { DistributionChart, defaultPlot, makePlot } from "../DistributionChart";
import { FunctionChart, FunctionChartSettings } from "../FunctionChart"; import { FunctionChart } from "../FunctionChart";
import clsx from "clsx"; import clsx from "clsx";
import { VariableBox } from "./VariableBox"; import { VariableBox } from "./VariableBox";
import { ItemSettingsMenu } from "./ItemSettingsMenu"; import { ItemSettingsMenu } from "./ItemSettingsMenu";
import { hasMassBelowZero } from "../../lib/distributionUtils"; import { hasMassBelowZero } from "../../lib/distributionUtils";
import { MergedItemSettings } from "./utils"; import { MergedItemSettings } from "./utils";
import { ViewerContext } from "./ViewerContext";
/*
// DISABLED FOR 0.4 branch, for now
function getRange<a>(x: declaration<a>) { function getRange<a>(x: declaration<a>) {
const first = x.args[0]; const first = x.args[0];
switch (first.tag) { switch (first.tag) {
@ -31,15 +34,21 @@ function getChartSettings<a>(x: declaration<a>): FunctionChartSettings {
count: 20, count: 20,
}; };
} }
*/
const VariableList: React.FC<{ const VariableList: React.FC<{
path: string[]; value: SqValue;
heading: string; heading: string;
children: (settings: MergedItemSettings) => React.ReactNode; children: (settings: MergedItemSettings) => React.ReactNode;
}> = ({ path, heading, children }) => ( }> = ({ value, heading, children }) => (
<VariableBox path={path} heading={heading}> <VariableBox value={value} heading={heading}>
{(settings) => ( {(settings) => (
<div className={clsx("space-y-3", path.length ? "pt-1 mt-1" : null)}> <div
className={clsx(
"space-y-3",
value.location.path.items.length ? "pt-1 mt-1" : null
)}
>
{children(settings)} {children(settings)}
</div> </div>
)} )}
@ -48,51 +57,44 @@ const VariableList: React.FC<{
export interface Props { export interface Props {
/** The output of squiggle's run */ /** The output of squiggle's run */
expression: squiggleExpression; value: SqValue;
/** Path to the current item, e.g. `['foo', 'bar', '3']` for `foo.bar[3]`; can be empty on the top-level item. */
path: string[];
width?: number; width?: number;
} }
export const ExpressionViewer: React.FC<Props> = ({ export const ExpressionViewer: React.FC<Props> = ({ value, width }) => {
path, const { getMergedSettings } = useContext(ViewerContext);
expression,
width, switch (value.tag) {
}) => { case SqValueTag.Number:
if (typeof expression !== "object") {
return (
<VariableList path={path} heading="Error">
{() => `Unknown expression: ${expression}`}
</VariableList>
);
}
switch (expression.tag) {
case "number":
return ( return (
<VariableBox path={path} heading="Number"> <VariableBox value={value} heading="Number">
{() => ( {() => (
<div className="font-semibold text-slate-600"> <div className="font-semibold text-slate-600">
<NumberShower precision={3} number={expression.value} /> <NumberShower precision={3} number={value.value} />
</div> </div>
)} )}
</VariableBox> </VariableBox>
); );
case "distribution": { case SqValueTag.Distribution: {
const distType = expression.value.type(); const distType = value.value.tag;
return ( return (
<VariableBox <VariableBox
path={path} value={value}
heading={`Distribution (${distType})\n${ heading={`Distribution (${distType})\n${
distType === "Symbolic" ? expression.value.toString() : "" distType === SqDistributionTag.Symbolic
? value.value.toString()
: ""
}`} }`}
renderSettingsMenu={({ onChange }) => { renderSettingsMenu={({ onChange }) => {
const shape = expression.value.pointSet(); const shape = value.value.pointSet(
getMergedSettings(value.location).environment
);
return ( return (
<ItemSettingsMenu <ItemSettingsMenu
path={path} value={value}
onChange={onChange} onChange={onChange}
disableLogX={ disableLogX={
shape.tag === "Ok" && hasMassBelowZero(shape.value) shape.tag === "Ok" && hasMassBelowZero(shape.value.asShape())
} }
withFunctionSettings={false} withFunctionSettings={false}
/> />
@ -102,7 +104,8 @@ export const ExpressionViewer: React.FC<Props> = ({
{(settings) => { {(settings) => {
return ( return (
<DistributionChart <DistributionChart
distribution={expression.value} plot={defaultPlot(value.value)}
environment={settings.environment}
{...settings.distributionPlotSettings} {...settings.distributionPlotSettings}
height={settings.height} height={settings.height}
width={width} width={width}
@ -112,77 +115,54 @@ export const ExpressionViewer: React.FC<Props> = ({
</VariableBox> </VariableBox>
); );
} }
case "string": case SqValueTag.String:
return ( return (
<VariableBox path={path} heading="String"> <VariableBox value={value} heading="String">
{() => ( {() => (
<> <>
<span className="text-slate-400">"</span> <span className="text-slate-400">"</span>
<span className="text-slate-600 font-semibold font-mono"> <span className="text-slate-600 font-semibold font-mono">
{expression.value} {value.value}
</span> </span>
<span className="text-slate-400">"</span> <span className="text-slate-400">"</span>
</> </>
)} )}
</VariableBox> </VariableBox>
); );
case "boolean": case SqValueTag.Bool:
return ( return (
<VariableBox path={path} heading="Boolean"> <VariableBox value={value} heading="Boolean">
{() => expression.value.toString()} {() => value.value.toString()}
</VariableBox> </VariableBox>
); );
case "symbol": case SqValueTag.Date:
return ( return (
<VariableBox path={path} heading="Symbol"> <VariableBox value={value} heading="Date">
{() => ( {() => value.value.toDateString()}
<>
<span className="text-slate-500 mr-2">Undefined Symbol:</span>
<span className="text-slate-600">{expression.value}</span>
</>
)}
</VariableBox> </VariableBox>
); );
case "call": case SqValueTag.Void:
return ( return (
<VariableBox path={path} heading="Call"> <VariableBox value={value} heading="Void">
{() => expression.value}
</VariableBox>
);
case "arraystring":
return (
<VariableBox path={path} heading="Array String">
{() => expression.value.map((r) => `"${r}"`).join(", ")}
</VariableBox>
);
case "date":
return (
<VariableBox path={path} heading="Date">
{() => expression.value.toDateString()}
</VariableBox>
);
case "void":
return (
<VariableBox path={path} heading="Void">
{() => "Void"} {() => "Void"}
</VariableBox> </VariableBox>
); );
case "timeDuration": { case SqValueTag.TimeDuration: {
return ( return (
<VariableBox path={path} heading="Time Duration"> <VariableBox value={value} heading="Time Duration">
{() => <NumberShower precision={3} number={expression.value} />} {() => <NumberShower precision={3} number={value.value} />}
</VariableBox> </VariableBox>
); );
} }
case "lambda": case SqValueTag.Lambda:
return ( return (
<VariableBox <VariableBox
path={path} value={value}
heading="Function" heading="Function"
renderSettingsMenu={({ onChange }) => { renderSettingsMenu={({ onChange }) => {
return ( return (
<ItemSettingsMenu <ItemSettingsMenu
path={path} value={value}
onChange={onChange} onChange={onChange}
withFunctionSettings={true} withFunctionSettings={true}
/> />
@ -191,11 +171,11 @@ export const ExpressionViewer: React.FC<Props> = ({
> >
{(settings) => ( {(settings) => (
<> <>
<div className="text-amber-700 bg-amber-100 rounded-md font-mono p-1 pl-2 mb-3 mt-1 text-sm">{`function(${expression.value.parameters.join( <div className="text-amber-700 bg-amber-100 rounded-md font-mono p-1 pl-2 mb-3 mt-1 text-sm">{`function(${value.value
"," .parameters()
)})`}</div> .join(",")})`}</div>
<FunctionChart <FunctionChart
fn={expression.value} fn={value.value}
chartSettings={settings.chartSettings} chartSettings={settings.chartSettings}
distributionPlotSettings={settings.distributionPlotSettings} distributionPlotSettings={settings.distributionPlotSettings}
height={settings.height} height={settings.height}
@ -208,92 +188,118 @@ export const ExpressionViewer: React.FC<Props> = ({
)} )}
</VariableBox> </VariableBox>
); );
case "lambdaDeclaration": { case SqValueTag.Declaration: {
return ( return (
<VariableBox <VariableBox
path={path} value={value}
heading="Function Declaration" heading="Function Declaration"
renderSettingsMenu={({ onChange }) => { renderSettingsMenu={({ onChange }) => {
return ( return (
<ItemSettingsMenu <ItemSettingsMenu
onChange={onChange} onChange={onChange}
path={path} value={value}
withFunctionSettings={true} withFunctionSettings={true}
/> />
); );
}} }}
> >
{(settings) => ( {(settings) => (
<FunctionChart <div>NOT IMPLEMENTED IN 0.4 YET</div>
fn={expression.value.fn} // <FunctionChart
chartSettings={getChartSettings(expression.value)} // fn={expression.value.fn}
distributionPlotSettings={settings.distributionPlotSettings} // chartSettings={getChartSettings(expression.value)}
height={settings.height} // distributionPlotSettings={settings.distributionPlotSettings}
environment={{ // height={settings.height}
sampleCount: settings.environment.sampleCount / 10, // environment={{
xyPointLength: settings.environment.xyPointLength / 10, // sampleCount: settings.environment.sampleCount / 10,
}} // xyPointLength: settings.environment.xyPointLength / 10,
/> // }}
// />
)} )}
</VariableBox> </VariableBox>
); );
} }
case "module": { case SqValueTag.Record:
const plot = makePlot(value.value);
if (plot) {
return (
<VariableBox
value={value}
heading="Plot"
renderSettingsMenu={({ onChange }) => {
let disableLogX = plot.distributions.some((x) => {
let pointSet = x.distribution.pointSet(
getMergedSettings(value.location).environment
);
return (
pointSet.tag === "Ok" &&
hasMassBelowZero(pointSet.value.asShape())
);
});
return (
<ItemSettingsMenu
value={value}
onChange={onChange}
disableLogX={disableLogX}
withFunctionSettings={false}
/>
);
}}
>
{(settings) => {
return (
<DistributionChart
plot={plot}
environment={settings.environment}
{...settings.distributionPlotSettings}
height={settings.height}
width={width}
/>
);
}}
</VariableBox>
);
} else {
return (
<VariableList value={value} heading="Record">
{(_) =>
value.value
.entries()
.map(([key, r]) => (
<ExpressionViewer
key={key}
value={r}
width={width !== undefined ? width - 20 : width}
/>
))
}
</VariableList>
);
}
case SqValueTag.Array:
return ( return (
<VariableList path={path} heading="Module"> <VariableList value={value} heading="Array">
{(settings) => {(_) =>
Object.entries(expression.value) value.value
.filter(([key, r]) => !key.match(/^(Math|System)\./)) .getValues()
.map(([key, r]) => ( .map((r, i) => (
<ExpressionViewer <ExpressionViewer
key={key} key={i}
path={[...path, key]} value={r}
expression={r}
width={width !== undefined ? width - 20 : width} width={width !== undefined ? width - 20 : width}
/> />
)) ))
} }
</VariableList> </VariableList>
); );
}
case "record":
return (
<VariableList path={path} heading="Record">
{(settings) =>
Object.entries(expression.value).map(([key, r]) => (
<ExpressionViewer
key={key}
path={[...path, key]}
expression={r}
width={width !== undefined ? width - 20 : width}
/>
))
}
</VariableList>
);
case "array":
return (
<VariableList path={path} heading="Array">
{(settings) =>
expression.value.map((r, i) => (
<ExpressionViewer
key={i}
path={[...path, String(i)]}
expression={r}
width={width !== undefined ? width - 20 : width}
/>
))
}
</VariableList>
);
default: { default: {
return ( return (
<VariableList path={path} heading="Error"> <VariableList value={value} heading="Error">
{() => ( {() => (
<div> <div>
<span>No display for type: </span>{" "} <span>No display for type: </span>{" "}
<span className="font-semibold text-slate-600"> <span className="font-semibold text-slate-600">
{expression.tag} {(value as { tag: string }).tag}
</span> </span>
</div> </div>
)} )}

View File

@ -4,16 +4,14 @@ import { useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup"; import { yupResolver } from "@hookform/resolvers/yup";
import { Modal } from "../ui/Modal"; import { Modal } from "../ui/Modal";
import { ViewSettings, viewSettingsSchema } from "../ViewSettings"; import { ViewSettings, viewSettingsSchema } from "../ViewSettings";
import { Path, pathAsString } from "./utils";
import { ViewerContext } from "./ViewerContext"; import { ViewerContext } from "./ViewerContext";
import { import { defaultTickFormat } from "../../lib/distributionSpecBuilder";
defaultColor,
defaultTickFormat,
} from "../../lib/distributionSpecBuilder";
import { PlaygroundContext } from "../SquigglePlayground"; import { PlaygroundContext } from "../SquigglePlayground";
import { SqValue } from "@quri/squiggle-lang";
import { locationAsString } from "./utils";
type Props = { type Props = {
path: Path; value: SqValue;
onChange: () => void; onChange: () => void;
disableLogX?: boolean; disableLogX?: boolean;
withFunctionSettings: boolean; withFunctionSettings: boolean;
@ -22,7 +20,7 @@ type Props = {
const ItemSettingsModal: React.FC< const ItemSettingsModal: React.FC<
Props & { close: () => void; resetScroll: () => void } Props & { close: () => void; resetScroll: () => void }
> = ({ > = ({
path, value,
onChange, onChange,
disableLogX, disableLogX,
withFunctionSettings, withFunctionSettings,
@ -32,7 +30,7 @@ const ItemSettingsModal: React.FC<
const { setSettings, getSettings, getMergedSettings } = const { setSettings, getSettings, getMergedSettings } =
useContext(ViewerContext); useContext(ViewerContext);
const mergedSettings = getMergedSettings(path); const mergedSettings = getMergedSettings(value.location);
const { register, watch } = useForm({ const { register, watch } = useForm({
resolver: yupResolver(viewSettingsSchema), resolver: yupResolver(viewSettingsSchema),
@ -46,7 +44,6 @@ const ItemSettingsModal: React.FC<
tickFormat: tickFormat:
mergedSettings.distributionPlotSettings.format || defaultTickFormat, mergedSettings.distributionPlotSettings.format || defaultTickFormat,
title: mergedSettings.distributionPlotSettings.title, title: mergedSettings.distributionPlotSettings.title,
color: mergedSettings.distributionPlotSettings.color || defaultColor,
minX: mergedSettings.distributionPlotSettings.minX, minX: mergedSettings.distributionPlotSettings.minX,
maxX: mergedSettings.distributionPlotSettings.maxX, maxX: mergedSettings.distributionPlotSettings.maxX,
distributionChartActions: mergedSettings.distributionPlotSettings.actions, distributionChartActions: mergedSettings.distributionPlotSettings.actions,
@ -57,8 +54,8 @@ const ItemSettingsModal: React.FC<
}); });
useEffect(() => { useEffect(() => {
const subscription = watch((vars) => { const subscription = watch((vars) => {
const settings = getSettings(path); // get the latest version const settings = getSettings(value.location); // get the latest version
setSettings(path, { setSettings(value.location, {
...settings, ...settings,
distributionPlotSettings: { distributionPlotSettings: {
showSummary: vars.showSummary, showSummary: vars.showSummary,
@ -66,7 +63,6 @@ const ItemSettingsModal: React.FC<
expY: vars.expY, expY: vars.expY,
format: vars.tickFormat, format: vars.tickFormat,
title: vars.title, title: vars.title,
color: vars.color,
minX: vars.minX, minX: vars.minX,
maxX: vars.maxX, maxX: vars.maxX,
actions: vars.distributionChartActions, actions: vars.distributionChartActions,
@ -80,7 +76,7 @@ const ItemSettingsModal: React.FC<
onChange(); onChange();
}); });
return () => subscription.unsubscribe(); return () => subscription.unsubscribe();
}, [getSettings, setSettings, onChange, path, watch]); }, [getSettings, setSettings, onChange, value.location, watch]);
const { getLeftPanelElement } = useContext(PlaygroundContext); const { getLeftPanelElement } = useContext(PlaygroundContext);
@ -88,7 +84,7 @@ const ItemSettingsModal: React.FC<
<Modal container={getLeftPanelElement()} close={close}> <Modal container={getLeftPanelElement()} close={close}>
<Modal.Header> <Modal.Header>
Chart settings Chart settings
{path.length ? ( {value.location.path.items.length ? (
<> <>
{" for "} {" for "}
<span <span
@ -96,7 +92,7 @@ const ItemSettingsModal: React.FC<
className="cursor-pointer" className="cursor-pointer"
onClick={resetScroll} onClick={resetScroll}
> >
{pathAsString(path)} {locationAsString(value.location)}
</span>{" "} </span>{" "}
</> </>
) : ( ) : (
@ -125,7 +121,7 @@ export const ItemSettingsMenu: React.FC<Props> = (props) => {
if (!enableLocalSettings) { if (!enableLocalSettings) {
return null; return null;
} }
const settings = getSettings(props.path); const settings = getSettings(props.value.location);
const resetScroll = () => { const resetScroll = () => {
if (!ref.current) return; if (!ref.current) return;
@ -144,7 +140,7 @@ export const ItemSettingsMenu: React.FC<Props> = (props) => {
{settings.distributionPlotSettings || settings.chartSettings ? ( {settings.distributionPlotSettings || settings.chartSettings ? (
<button <button
onClick={() => { onClick={() => {
setSettings(props.path, { setSettings(props.value.location, {
...settings, ...settings,
distributionPlotSettings: undefined, distributionPlotSettings: undefined,
chartSettings: undefined, chartSettings: undefined,

View File

@ -1,3 +1,4 @@
import { SqValue } from "@quri/squiggle-lang";
import React, { useContext, useReducer } from "react"; import React, { useContext, useReducer } from "react";
import { Tooltip } from "../ui/Tooltip"; import { Tooltip } from "../ui/Tooltip";
import { LocalItemSettings, MergedItemSettings } from "./utils"; import { LocalItemSettings, MergedItemSettings } from "./utils";
@ -8,14 +9,14 @@ type SettingsMenuParams = {
}; };
type VariableBoxProps = { type VariableBoxProps = {
path: string[]; value: SqValue;
heading: string; heading: string;
renderSettingsMenu?: (params: SettingsMenuParams) => React.ReactNode; renderSettingsMenu?: (params: SettingsMenuParams) => React.ReactNode;
children: (settings: MergedItemSettings) => React.ReactNode; children: (settings: MergedItemSettings) => React.ReactNode;
}; };
export const VariableBox: React.FC<VariableBoxProps> = ({ export const VariableBox: React.FC<VariableBoxProps> = ({
path, value: { location },
heading = "Error", heading = "Error",
renderSettingsMenu, renderSettingsMenu,
children, children,
@ -27,10 +28,10 @@ export const VariableBox: React.FC<VariableBoxProps> = ({
// So we use `forceUpdate` to force rerendering. // So we use `forceUpdate` to force rerendering.
const [_, forceUpdate] = useReducer((x) => x + 1, 0); const [_, forceUpdate] = useReducer((x) => x + 1, 0);
const settings = getSettings(path); const settings = getSettings(location);
const setSettingsAndUpdate = (newSettings: LocalItemSettings) => { const setSettingsAndUpdate = (newSettings: LocalItemSettings) => {
setSettings(path, newSettings); setSettings(location, newSettings);
forceUpdate(); forceUpdate();
}; };
@ -38,11 +39,13 @@ export const VariableBox: React.FC<VariableBoxProps> = ({
setSettingsAndUpdate({ ...settings, collapsed: !settings.collapsed }); setSettingsAndUpdate({ ...settings, collapsed: !settings.collapsed });
}; };
const isTopLevel = path.length === 0; const isTopLevel = location.path.items.length === 0;
const name = isTopLevel ? "Result" : path[path.length - 1]; const name = isTopLevel
? { result: "Result", bindings: "Bindings" }[location.path.root]
: location.path.items[location.path.items.length - 1];
return ( return (
<div> <div role={isTopLevel ? "status" : undefined}>
<header className="inline-flex space-x-1"> <header className="inline-flex space-x-1">
<Tooltip text={heading}> <Tooltip text={heading}>
<span <span
@ -65,13 +68,13 @@ export const VariableBox: React.FC<VariableBoxProps> = ({
</header> </header>
{settings.collapsed ? null : ( {settings.collapsed ? null : (
<div className="flex w-full"> <div className="flex w-full">
{path.length ? ( {location.path.items.length ? (
<div <div
className="border-l-2 border-slate-200 hover:border-indigo-600 w-4 cursor-pointer" className="shrink-0 border-l-2 border-slate-200 hover:border-indigo-600 w-4 cursor-pointer"
onClick={toggleCollapsed} onClick={toggleCollapsed}
></div> ></div>
) : null} ) : null}
<div className="grow">{children(getMergedSettings(path))}</div> <div className="grow">{children(getMergedSettings(location))}</div>
</div> </div>
)} )}
</div> </div>

View File

@ -1,14 +1,14 @@
import { defaultEnvironment } from "@quri/squiggle-lang"; import { defaultEnvironment, SqValueLocation } from "@quri/squiggle-lang";
import React from "react"; import React from "react";
import { LocalItemSettings, MergedItemSettings, Path } from "./utils"; import { LocalItemSettings, MergedItemSettings } from "./utils";
type ViewerContextShape = { type ViewerContextShape = {
// Note that we don't store settings themselves in the context (that would cause rerenders of the entire tree on each settings update). // Note that we don't store settings themselves in the context (that would cause rerenders of the entire tree on each settings update).
// Instead, we keep settings in local state and notify the global context via setSettings to pass them down the component tree again if it got rebuilt from scratch. // Instead, we keep settings in local state and notify the global context via setSettings to pass them down the component tree again if it got rebuilt from scratch.
// See ./SquiggleViewer.tsx and ./VariableBox.tsx for other implementation details on this. // See ./SquiggleViewer.tsx and ./VariableBox.tsx for other implementation details on this.
getSettings(path: Path): LocalItemSettings; getSettings(location: SqValueLocation): LocalItemSettings;
getMergedSettings(path: Path): MergedItemSettings; getMergedSettings(location: SqValueLocation): MergedItemSettings;
setSettings(path: Path, value: LocalItemSettings): void; setSettings(location: SqValueLocation, value: LocalItemSettings): void;
enableLocalSettings: boolean; // show local settings icon in the UI enableLocalSettings: boolean; // show local settings icon in the UI
}; };

View File

@ -1,21 +1,20 @@
import React, { useCallback, useRef } from "react"; import React, { useCallback, useRef } from "react";
import { environment } from "@quri/squiggle-lang"; import { environment, SqValueLocation } from "@quri/squiggle-lang";
import { DistributionPlottingSettings } from "../DistributionChart"; import { DistributionPlottingSettings } from "../DistributionChart";
import { FunctionChartSettings } from "../FunctionChart"; import { FunctionChartSettings } from "../FunctionChart";
import { ExpressionViewer } from "./ExpressionViewer"; import { ExpressionViewer } from "./ExpressionViewer";
import { ViewerContext } from "./ViewerContext"; import { ViewerContext } from "./ViewerContext";
import { import {
LocalItemSettings, LocalItemSettings,
locationAsString,
MergedItemSettings, MergedItemSettings,
Path,
pathAsString,
} from "./utils"; } from "./utils";
import { useSquiggle } from "../../lib/hooks"; import { useSquiggle } from "../../lib/hooks";
import { SquiggleErrorAlert } from "../SquiggleErrorAlert"; import { SquiggleErrorAlert } from "../SquiggleErrorAlert";
type Props = { type Props = {
/** The output of squiggle's run */ /** The output of squiggle's run */
result: ReturnType<typeof useSquiggle>; result: ReturnType<typeof useSquiggle>["result"];
width?: number; width?: number;
height: number; height: number;
distributionPlotSettings: DistributionPlottingSettings; distributionPlotSettings: DistributionPlottingSettings;
@ -45,22 +44,22 @@ export const SquiggleViewer: React.FC<Props> = ({
const settingsRef = useRef<Settings>({}); const settingsRef = useRef<Settings>({});
const getSettings = useCallback( const getSettings = useCallback(
(path: Path) => { (location: SqValueLocation) => {
return settingsRef.current[pathAsString(path)] || defaultSettings; return settingsRef.current[locationAsString(location)] || defaultSettings;
}, },
[settingsRef] [settingsRef]
); );
const setSettings = useCallback( const setSettings = useCallback(
(path: Path, value: LocalItemSettings) => { (location: SqValueLocation, value: LocalItemSettings) => {
settingsRef.current[pathAsString(path)] = value; settingsRef.current[locationAsString(location)] = value;
}, },
[settingsRef] [settingsRef]
); );
const getMergedSettings = useCallback( const getMergedSettings = useCallback(
(path: Path) => { (location: SqValueLocation) => {
const localSettings = getSettings(path); const localSettings = getSettings(location);
const result: MergedItemSettings = { const result: MergedItemSettings = {
distributionPlotSettings: { distributionPlotSettings: {
...distributionPlotSettings, ...distributionPlotSettings,
@ -91,7 +90,7 @@ export const SquiggleViewer: React.FC<Props> = ({
}} }}
> >
{result.tag === "Ok" ? ( {result.tag === "Ok" ? (
<ExpressionViewer path={[]} expression={result.value} width={width} /> <ExpressionViewer value={result.value} width={width} />
) : ( ) : (
<SquiggleErrorAlert error={result.value} /> <SquiggleErrorAlert error={result.value} />
)} )}

View File

@ -1,6 +1,6 @@
import { DistributionPlottingSettings } from "../DistributionChart"; import { DistributionPlottingSettings } from "../DistributionChart";
import { FunctionChartSettings } from "../FunctionChart"; import { FunctionChartSettings } from "../FunctionChart";
import { environment } from "@quri/squiggle-lang"; import { environment, SqValueLocation } from "@quri/squiggle-lang";
export type LocalItemSettings = { export type LocalItemSettings = {
collapsed: boolean; collapsed: boolean;
@ -17,6 +17,5 @@ export type MergedItemSettings = {
environment: environment; environment: environment;
}; };
export type Path = string[]; export const locationAsString = (location: SqValueLocation) =>
location.path.items.join(".");
export const pathAsString = (path: Path) => path.join(".");

View File

@ -5,10 +5,7 @@ import { InputItem } from "./ui/InputItem";
import { Checkbox } from "./ui/Checkbox"; import { Checkbox } from "./ui/Checkbox";
import { HeadedSection } from "./ui/HeadedSection"; import { HeadedSection } from "./ui/HeadedSection";
import { Text } from "./ui/Text"; import { Text } from "./ui/Text";
import { import { defaultTickFormat } from "../lib/distributionSpecBuilder";
defaultColor,
defaultTickFormat,
} from "../lib/distributionSpecBuilder";
export const viewSettingsSchema = yup.object({}).shape({ export const viewSettingsSchema = yup.object({}).shape({
chartHeight: yup.number().required().positive().integer().default(350), chartHeight: yup.number().required().positive().integer().default(350),
@ -18,7 +15,6 @@ export const viewSettingsSchema = yup.object({}).shape({
expY: yup.boolean().required(), expY: yup.boolean().required(),
tickFormat: yup.string().default(defaultTickFormat), tickFormat: yup.string().default(defaultTickFormat),
title: yup.string(), title: yup.string(),
color: yup.string().default(defaultColor).required(),
minX: yup.number(), minX: yup.number(),
maxX: yup.number(), maxX: yup.number(),
distributionChartActions: yup.boolean(), distributionChartActions: yup.boolean(),
@ -114,12 +110,6 @@ export const ViewSettings: React.FC<{
register={register} register={register}
label="Tick Format" label="Tick Format"
/> />
<InputItem
name="color"
type="color"
register={register}
label="Color"
/>
</div> </div>
</HeadedSection> </HeadedSection>
</div> </div>

View File

@ -1,8 +1,8 @@
import clsx from "clsx"; import clsx from "clsx";
import React from "react"; import React from "react";
import { Path, UseFormRegister } from "react-hook-form"; import { Path, UseFormRegister, FieldValues } from "react-hook-form";
export function Checkbox<T>({ export function Checkbox<T extends FieldValues>({
name, name,
label, label,
register, register,

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Path, UseFormRegister } from "react-hook-form"; import { Path, UseFormRegister, FieldValues } from "react-hook-form";
export function InputItem<T>({ export function InputItem<T extends FieldValues>({
name, name,
label, label,
type, type,

View File

@ -1,7 +1,5 @@
export { SqProject } from "@quri/squiggle-lang/";
export { SquiggleChart } from "./components/SquiggleChart"; export { SquiggleChart } from "./components/SquiggleChart";
export { SquiggleEditor, SquigglePartial } from "./components/SquiggleEditor"; export { SquiggleEditor } from "./components/SquiggleEditor";
export { SquigglePlayground } from "./components/SquigglePlayground"; export { SquigglePlayground } from "./components/SquigglePlayground";
export { SquiggleContainer } from "./components/SquiggleContainer"; export { SquiggleContainer } from "./components/SquiggleContainer";
export { SquiggleEditorWithImportedBindings } from "./components/SquiggleEditorWithImportedBindings";
export { mergeBindings } from "@quri/squiggle-lang";

View File

@ -1,5 +1,5 @@
import { VisualizationSpec } from "react-vega"; import { VisualizationSpec } from "react-vega";
import type { LogScale, LinearScale, PowScale } from "vega"; import type { LogScale, LinearScale, PowScale, TimeScale } from "vega";
export type DistributionChartSpecOptions = { export type DistributionChartSpecOptions = {
/** Set the x scale to be logarithmic by deault */ /** Set the x scale to be logarithmic by deault */
@ -10,54 +10,25 @@ export type DistributionChartSpecOptions = {
minX?: number; minX?: number;
/** The maximum x coordinate shown on the chart */ /** The maximum x coordinate shown on the chart */
maxX?: number; maxX?: number;
/** The color of the chart */
color?: string;
/** The title of the chart */ /** The title of the chart */
title?: string; title?: string;
/** The formatting of the ticks */ /** The formatting of the ticks */
format?: string; format?: string;
/** Whether the x-axis should be dates or numbers */
xAxisType?: "number" | "dateTime";
}; };
export let linearXScale: LinearScale = { /** X Scales */
export const linearXScale: LinearScale = {
name: "xscale", name: "xscale",
clamp: true, clamp: true,
type: "linear", type: "linear",
range: "width", range: "width",
zero: false, zero: false,
nice: false, nice: false,
domain: {
fields: [
{
data: "con",
field: "x",
},
{
data: "dis",
field: "x",
},
],
},
};
export let linearYScale: LinearScale = {
name: "yscale",
type: "linear",
range: "height",
zero: true,
domain: {
fields: [
{
data: "con",
field: "y",
},
{
data: "dis",
field: "y",
},
],
},
}; };
export let logXScale: LogScale = { export const logXScale: LogScale = {
name: "xscale", name: "xscale",
type: "log", type: "log",
range: "width", range: "width",
@ -65,82 +36,114 @@ export let logXScale: LogScale = {
base: 10, base: 10,
nice: false, nice: false,
clamp: true, clamp: true,
domain: {
fields: [
{
data: "con",
field: "x",
},
{
data: "dis",
field: "x",
},
],
},
}; };
export let expYScale: PowScale = { export const timeXScale: TimeScale = {
name: "xscale",
clamp: true,
type: "time",
range: "width",
nice: false,
};
/** Y Scales */
export const linearYScale: LinearScale = {
name: "yscale",
type: "linear",
range: "height",
zero: true,
};
export const expYScale: PowScale = {
name: "yscale", name: "yscale",
type: "pow", type: "pow",
exponent: 0.1, exponent: 0.1,
range: "height", range: "height",
zero: true, zero: true,
nice: false, nice: false,
domain: {
fields: [
{
data: "con",
field: "y",
},
{
data: "dis",
field: "y",
},
],
},
}; };
export const defaultTickFormat = ".9~s"; export const defaultTickFormat = ".9~s";
export const defaultColor = "#739ECC"; export const timeTickFormat = "%b %d, %Y %H:%M";
const width = 500;
export function buildVegaSpec( export function buildVegaSpec(
specOptions: DistributionChartSpecOptions specOptions: DistributionChartSpecOptions & { maxY: number }
): VisualizationSpec { ): VisualizationSpec {
let { const {
format = defaultTickFormat,
color = defaultColor,
title, title,
minX, minX,
maxX, maxX,
logX, logX,
expY, expY,
xAxisType = "number",
maxY,
} = specOptions; } = specOptions;
let xScale = logX ? logXScale : linearXScale; const dateTime = xAxisType === "dateTime";
if (minX !== undefined && Number.isFinite(minX)) {
xScale = { ...xScale, domainMin: minX };
}
if (maxX !== undefined && Number.isFinite(maxX)) { // some fallbacks
xScale = { ...xScale, domainMax: maxX }; const format = specOptions?.format
} ? specOptions.format
: dateTime
? timeTickFormat
: defaultTickFormat;
let spec: VisualizationSpec = { let xScale = dateTime ? timeXScale : logX ? logXScale : linearXScale;
xScale = {
...xScale,
domain: [minX ?? 0, maxX ?? 1],
domainMin: minX,
domainMax: maxX,
};
let yScale = expY ? expYScale : linearYScale;
yScale = { ...yScale, domain: [0, maxY ?? 1], domainMin: 0, domainMax: maxY };
const spec: VisualizationSpec = {
$schema: "https://vega.github.io/schema/vega/v5.json", $schema: "https://vega.github.io/schema/vega/v5.json",
description: "A basic area chart example", description: "Squiggle plot chart",
width: 500, width: width,
height: 100, height: 100,
padding: 5, padding: 5,
data: [ data: [{ name: "data" }, { name: "domain" }, { name: "samples" }],
signals: [
{ {
name: "con", name: "hover",
value: null,
on: [
{ events: "mouseover", update: "datum" },
{ events: "mouseout", update: "null" },
],
}, },
{ {
name: "dis", name: "position",
value: "[0, 0]",
on: [
{ events: "mousemove", update: "xy() " },
{ events: "mouseout", update: "null" },
],
},
{
name: "position_scaled",
value: null,
update: "isArray(position) ? invert('xscale', position[0]) : ''",
},
],
scales: [
xScale,
yScale,
{
name: "color",
type: "ordinal",
domain: {
data: "data",
field: "name",
},
range: { scheme: "blues" },
}, },
], ],
signals: [],
scales: [xScale, expY ? expYScale : linearYScale],
axes: [ axes: [
{ {
orient: "bottom", orient: "bottom",
@ -151,109 +154,245 @@ export function buildVegaSpec(
domainColor: "#fff", domainColor: "#fff",
domainOpacity: 0.0, domainOpacity: 0.0,
format: format, format: format,
tickCount: 10, tickCount: dateTime ? 3 : 10,
labelOverlap: "greedy",
}, },
], ],
marks: [ marks: [
{ {
type: "area", name: "all_distributions",
type: "group",
from: { from: {
data: "con", facet: {
}, name: "distribution_facet",
encode: { data: "data",
update: { groupby: ["name"],
interpolate: { value: "linear" },
x: {
scale: "xscale",
field: "x",
},
y: {
scale: "yscale",
field: "y",
},
y2: {
scale: "yscale",
value: 0,
},
fill: {
value: color,
},
fillOpacity: {
value: 1,
},
}, },
}, },
marks: [
{
name: "continuous_distribution",
type: "group",
from: {
facet: {
name: "continuous_facet",
data: "distribution_facet",
field: "continuous",
},
},
encode: {
update: {},
},
marks: [
{
name: "continuous_area",
type: "area",
from: {
data: "continuous_facet",
},
encode: {
update: {
interpolate: { value: "linear" },
x: {
scale: "xscale",
field: "x",
},
y: {
scale: "yscale",
field: "y",
},
fill: {
scale: "color",
field: { parent: "name" },
},
y2: {
scale: "yscale",
value: 0,
},
fillOpacity: {
value: 1,
},
},
},
},
],
},
{
name: "discrete_distribution",
type: "group",
from: {
facet: {
name: "discrete_facet",
data: "distribution_facet",
field: "discrete",
},
},
marks: [
{
type: "rect",
from: {
data: "discrete_facet",
},
encode: {
enter: {
width: {
value: 1,
},
},
update: {
x: {
scale: "xscale",
field: "x",
},
y: {
scale: "yscale",
field: "y",
},
y2: {
scale: "yscale",
value: 0,
},
fill: {
scale: "color",
field: { parent: "name" },
},
},
},
},
{
type: "symbol",
from: {
data: "discrete_facet",
},
encode: {
enter: {
shape: {
value: "circle",
},
size: [{ value: 100 }],
tooltip: {
signal: dateTime
? "{ probability: datum.y, value: datetime(datum.x) }"
: "{ probability: datum.y, value: datum.x }",
},
},
update: {
x: {
scale: "xscale",
field: "x",
offset: 0.5, // if this is not included, the circles are slightly left of center.
},
y: {
scale: "yscale",
field: "y",
},
fill: {
scale: "color",
field: { parent: "name" },
},
},
},
},
],
},
],
}, },
{ {
name: "sampleset",
type: "rect", type: "rect",
from: { from: { data: "samples" },
data: "dis",
},
encode: { encode: {
enter: { enter: {
width: { x: { scale: "xscale", field: "data" },
value: 1, width: { value: 0.1 },
},
y: { value: 25, offset: { signal: "height" } },
height: { value: 5 },
},
},
},
{
type: "text",
name: "announcer",
interactive: false,
encode: {
enter: {
x: { signal: String(width), offset: 1 }, // vega would prefer its internal ` "width" ` variable, but that breaks the squiggle playground. Just setting it to the same var as used elsewhere in the spec achieves the same result.
fill: { value: "black" },
fontSize: { value: 20 },
align: { value: "right" },
}, },
update: { update: {
x: { text: {
scale: "xscale", signal: dateTime
field: "x", ? "position_scaled ? utcyear(position_scaled) + '-' + utcmonth(position_scaled) + '-' + utcdate(position_scaled) + 'T' + utchours(position_scaled)+':' +utcminutes(position_scaled) : ''"
}, : "position_scaled ? format(position_scaled, ',.4r') : ''",
y: {
scale: "yscale",
field: "y",
},
y2: {
scale: "yscale",
value: 0,
},
fill: {
value: "#2f65a7",
}, },
}, },
}, },
}, },
{ {
type: "symbol", type: "rule",
from: { interactive: false,
data: "dis",
},
encode: { encode: {
enter: { enter: {
shape: { x: { value: 0 },
value: "circle", y: { scale: "yscale", value: 0 },
},
size: [{ value: 100 }], y2: {
tooltip: { signal: "height",
signal: "{ probability: datum.y, value: datum.x }", offset: 2,
}, },
strokeDash: { value: [5, 5] },
}, },
update: { update: {
x: { x: {
scale: "xscale", signal:
field: "x", "position ? position[0] < 0 ? null : position[0] > width ? null : position[0]: null",
}, },
y: {
scale: "yscale", opacity: {
field: "y", signal:
}, "position ? position[0] < 0 ? 0 : position[0] > width ? 0 : 1 : 0",
fill: {
value: "#1e4577",
}, },
}, },
}, },
}, },
], ],
}; legends: [
if (title) { {
spec = { fill: "color",
...spec, orient: "top",
labelFontSize: 12,
encode: {
symbols: {
update: {
fill: [
{ test: "length(domain('color')) == 1", value: "transparent" },
{ scale: "color", field: "value" },
],
},
},
labels: {
interactive: true,
update: {
fill: [
{ test: "length(domain('color')) == 1", value: "transparent" },
{ value: "black" },
],
},
},
},
},
],
...(title && {
title: { title: {
text: title, text: title,
}, },
}; }),
} };
return spec; return spec;
} }

View File

@ -1,5 +1,5 @@
import { shape } from "@quri/squiggle-lang"; import { SqShape } from "@quri/squiggle-lang";
export const hasMassBelowZero = (shape: shape) => export const hasMassBelowZero = (shape: SqShape) =>
shape.continuous.some((x) => x.x <= 0) || shape.continuous.some((x) => x.x <= 0) ||
shape.discrete.some((x) => x.x <= 0); shape.discrete.some((x) => x.x <= 0);

View File

@ -1,3 +1,3 @@
export { useMaybeControlledValue } from "./useMaybeControlledValue"; export { useMaybeControlledValue } from "./useMaybeControlledValue";
export { useSquiggle, useSquigglePartial } from "./useSquiggle"; export { useSquiggle } from "./useSquiggle";
export { useRunnerState } from "./useRunnerState"; export { useRunnerState } from "./useRunnerState";

View File

@ -1,53 +1,97 @@
import { import {
bindings, result,
SqError,
SqProject,
SqRecord,
SqValue,
environment, environment,
jsImports,
run,
runPartial,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { useEffect, useMemo } from "react"; import { useEffect, useMemo } from "react";
import { JsImports, jsImportsToSquiggleCode } from "../jsImports";
import * as uuid from "uuid";
type SquiggleArgs<T extends ReturnType<typeof run | typeof runPartial>> = { type SquiggleArgs = {
environment?: environment;
code: string; code: string;
executionId?: number; executionId?: number;
bindings?: bindings; jsImports?: JsImports;
jsImports?: jsImports; project?: SqProject;
environment?: environment; continues?: string[];
onChange?: (expr: Extract<T, { tag: "Ok" }>["value"] | undefined) => void; onChange?: (expr: SqValue | undefined, sourceName: string) => void;
}; };
const useSquiggleAny = <T extends ReturnType<typeof run | typeof runPartial>>( export type ResultAndBindings = {
args: SquiggleArgs<T>, result: result<SqValue, SqError>;
f: (...args: Parameters<typeof run>) => T bindings: SqRecord;
) => { };
const result: T = useMemo<T>(
() => f(args.code, args.bindings, args.environment, args.jsImports), const importSourceName = (sourceName: string) => "imports-" + sourceName;
const defaultContinues = [];
export const useSquiggle = (args: SquiggleArgs): ResultAndBindings => {
const project = useMemo(() => {
if (args.project) {
return args.project;
} else {
const p = SqProject.create();
if (args.environment) {
p.setEnvironment(args.environment);
}
return p;
}
}, [args.project, args.environment]);
const sourceName = useMemo(() => uuid.v4(), []);
const env = project.getEnvironment();
const continues = args.continues || defaultContinues;
const result = useMemo(
() => {
project.setSource(sourceName, args.code);
let fullContinues = continues;
if (args.jsImports && Object.keys(args.jsImports).length) {
const importsSource = jsImportsToSquiggleCode(args.jsImports);
project.setSource(importSourceName(sourceName), importsSource);
fullContinues = continues.concat(importSourceName(sourceName));
}
project.setContinues(sourceName, fullContinues);
project.run(sourceName);
const result = project.getResult(sourceName);
const bindings = project.getBindings(sourceName);
return { result, bindings };
},
// This complains about executionId not being used inside the function body.
// This is on purpose, as executionId simply allows you to run the squiggle
// code again
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
[ [
f,
args.code, args.code,
args.bindings,
args.environment,
args.jsImports, args.jsImports,
args.executionId, args.executionId,
sourceName,
continues,
project,
env,
] ]
); );
const { onChange } = args; const { onChange } = args;
useEffect(() => { useEffect(() => {
onChange?.(result.tag === "Ok" ? result.value : undefined); onChange?.(
}, [result, onChange]); result.result.tag === "Ok" ? result.result.value : undefined,
sourceName
);
}, [result, onChange, sourceName]);
useEffect(() => {
return () => {
project.removeSource(sourceName);
if (project.getSource(importSourceName(sourceName)))
project.removeSource(importSourceName(sourceName));
};
}, [project, sourceName]);
return result; return result;
}; };
export const useSquigglePartial = (
args: SquiggleArgs<ReturnType<typeof runPartial>>
) => {
return useSquiggleAny(args, runPartial);
};
export const useSquiggle = (args: SquiggleArgs<ReturnType<typeof run>>) => {
return useSquiggleAny(args, run);
};

View File

@ -0,0 +1,51 @@
type JsImportsValue =
| number
| string
| JsImportsValue[]
| {
[k: string]: JsImportsValue;
};
export type JsImports = {
[k: string]: JsImportsValue;
};
const quote = (arg: string) => `"${arg.replace(new RegExp('"', "g"), '\\"')}"`;
const jsImportsValueToSquiggleCode = (v: JsImportsValue): string => {
if (typeof v === "number") {
return String(v);
} else if (typeof v === "string") {
return quote(v);
} else if (v instanceof Array) {
return "[" + v.map((x) => jsImportsValueToSquiggleCode(x)) + "]";
} else {
if (Object.keys(v).length) {
return (
"{" +
Object.entries(v)
.map(([k, v]) => `${quote(k)}:${jsImportsValueToSquiggleCode(v)},`)
.join("") +
"}"
);
} else {
return "0"; // squiggle doesn't support empty `{}`
}
}
};
export const jsImportsToSquiggleCode = (v: JsImports) => {
const validId = new RegExp("[a-zA-Z][[a-zA-Z0-9]*");
let result = Object.entries(v)
.map(([k, v]) => {
if (!k.match(validId)) {
return ""; // skipping without warnings; can be improved
}
return `$${k} = ${jsImportsValueToSquiggleCode(v)}\n`;
})
.join("");
if (!result) {
result = "$__no_valid_imports__ = 1"; // without this generated squiggle code can be invalid
}
return result;
};

View File

@ -0,0 +1,83 @@
import * as yup from "yup";
import {
SqValue,
SqValueTag,
SqDistribution,
result,
SqRecord,
} from "@quri/squiggle-lang";
export type LabeledDistribution = {
name: string;
distribution: SqDistribution;
color?: string;
};
export type Plot = {
distributions: LabeledDistribution[];
};
function error<a, b>(err: b): result<a, b> {
return { tag: "Error", value: err };
}
function ok<a, b>(x: a): result<a, b> {
return { tag: "Ok", value: x };
}
const schema = yup
.object()
.noUnknown()
.strict()
.shape({
distributions: yup
.array()
.required()
.of(
yup.object().required().shape({
name: yup.string().required(),
distribution: yup.mixed().required(),
})
),
});
type JsonObject =
| string
| { [key: string]: JsonObject }
| JsonObject[]
| SqDistribution;
function toJson(val: SqValue): JsonObject {
if (val.tag === SqValueTag.String) {
return val.value;
} else if (val.tag === SqValueTag.Record) {
return toJsonRecord(val.value);
} else if (val.tag === SqValueTag.Array) {
return val.value.getValues().map(toJson);
} else if (val.tag === SqValueTag.Distribution) {
return val.value;
} else {
throw new Error("Could not parse object of type " + val.tag);
}
}
function toJsonRecord(val: SqRecord): JsonObject {
let recordObject: JsonObject = {};
val.entries().forEach(([key, value]) => (recordObject[key] = toJson(value)));
return recordObject;
}
export function parsePlot(record: SqRecord): result<Plot, string> {
try {
const plotRecord = schema.validateSync(toJsonRecord(record));
if (plotRecord.distributions) {
return ok({ distributions: plotRecord.distributions.map((x) => x) });
} else {
// I have no idea why yup's typings thinks this is possible
return error("no distributions field. Should never get here");
}
} catch (e) {
const message = e instanceof Error ? e.message : "Unknown error";
return error(message);
}
}

View File

@ -0,0 +1,53 @@
import { result, resultMap, SqValueTag } from "@quri/squiggle-lang";
import { ResultAndBindings } from "./hooks/useSquiggle";
export function flattenResult<a, b>(x: result<a, b>[]): result<a[], b> {
if (x.length === 0) {
return { tag: "Ok", value: [] };
} else {
if (x[0].tag === "Error") {
return x[0];
} else {
let rest = flattenResult(x.splice(1));
if (rest.tag === "Error") {
return rest;
} else {
return { tag: "Ok", value: [x[0].value].concat(rest.value) };
}
}
}
}
export function resultBind<a, b, c>(
x: result<a, b>,
fn: (y: a) => result<c, b>
): result<c, b> {
if (x.tag === "Ok") {
return fn(x.value);
} else {
return x;
}
}
export function all(arr: boolean[]): boolean {
return arr.reduce((x, y) => x && y, true);
}
export function some(arr: boolean[]): boolean {
return arr.reduce((x, y) => x || y, false);
}
export function getValueToRender({ result, bindings }: ResultAndBindings) {
return resultMap(result, (value) =>
value.tag === SqValueTag.Void ? bindings.asValue() : value
);
}
export function getErrorLocations(result: ResultAndBindings["result"]) {
if (result.tag === "Error") {
const location = result.value.location();
return location ? [location] : [];
} else {
return [];
}
}

View File

@ -79,6 +79,22 @@ could be continuous, discrete or mixed.
</Story> </Story>
</Canvas> </Canvas>
### Date Distribution
<Canvas>
<Story
name="Date Distribution"
args={{
code: "mx(1661819770311, 1661829770311, 1661839770311)",
width,
xAxisType: "dateTime",
width,
}}
>
{Template.bind({})}
</Story>
</Canvas>
## Mixed distributions ## Mixed distributions
<Canvas> <Canvas>
@ -93,6 +109,33 @@ could be continuous, discrete or mixed.
</Story> </Story>
</Canvas> </Canvas>
## Multiple plots
<Canvas>
<Story
name="Multiple plots"
args={{
code: `
{
distributions: [
{
name: "one",
distribution: mx(0.5, normal(0,1))
},
{
name: "two",
distribution: mx(2, normal(5, 2)),
}
]
}
`,
width,
}}
>
{Template.bind({})}
</Story>
</Canvas>
## Constants ## Constants
A constant is a simple number as a result. This has special formatting rules A constant is a simple number as a result. This has special formatting rules

View File

@ -1,51 +0,0 @@
import { SquigglePartial, SquiggleEditor } from "../components/SquiggleEditor";
import { useState } from "react";
import { Canvas, Meta, Story, Props } from "@storybook/addon-docs";
<Meta title="Squiggle/SquigglePartial" component={SquigglePartial} />
export const Template = (props) => <SquigglePartial {...props} />;
# Squiggle Partial
A Squiggle Partial is an editor that does not return a graph to the user, but
instead returns bindings that can be used by further Squiggle Editors.
<Canvas>
<Story
name="Standalone"
args={{
defaultCode: "x = normal(5,2)",
}}
>
{Template.bind({})}
</Story>
</Canvas>
<Canvas>
<Story
name="With Editor"
args={{
initialPartialString: "x = normal(5,2)",
initialEditorString: "x",
}}
>
{(props) => {
let [bindings, setBindings] = useState({});
return (
<>
<SquigglePartial
{...props}
defaultCode={props.initialPartialString}
onChange={setBindings}
/>
<SquiggleEditor
{...props}
defaultCode={props.initialEditorString}
bindings={bindings}
/>
</>
);
}}
</Story>
</Canvas>

View File

@ -22,3 +22,8 @@ but this line is still necessary for proper initialization of `--tw-*` variables
.ace_cursor { .ace_cursor {
border-left: 2px solid !important; border-left: 2px solid !important;
} }
.ace-error-marker {
position: absolute;
border-bottom: 1px solid red;
}

View File

@ -0,0 +1,55 @@
import { render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import * as React from "react";
import "@testing-library/jest-dom";
import { SquigglePlayground } from "../src/index";
test("Autorun is default", async () => {
render(<SquigglePlayground code="70*30" />);
await waitFor(() =>
expect(screen.getByTestId("playground-result")).toHaveTextContent("2100")
);
});
test("Autorun can be switched off", async () => {
const user = userEvent.setup();
render(<SquigglePlayground code="70*30" />);
expect(screen.getByTestId("autorun-controls")).toHaveTextContent("Autorun");
await waitFor(() =>
expect(screen.getByTestId("playground-result")).toHaveTextContent("2100")
);
await user.click(screen.getByText("Autorun")); // disable
expect(screen.getByTestId("autorun-controls")).toHaveTextContent("Paused");
expect(screen.getByTestId("autorun-controls")).not.toHaveTextContent(
"Autorun"
);
await user.click(screen.getByText("Paused")); // enable autorun again
expect(screen.getByTestId("autorun-controls")).toHaveTextContent("Autorun");
// we should replace the code here, but it's hard to update react-ace state via user events: https://github.com/securingsincity/react-ace/issues/923
// ...or replace react-ace with something else
// TODO:
/*
const editor = screen
.getByTestId("squiggle-editor")
.querySelector(".ace_editor") as HTMLElement;
editor.focus();
// await user.clear(editor);
await userEvent.paste("40*40"); // https://github.com/securingsincity/react-ace/issues/923#issuecomment-755502696
screen.debug(editor);
// this makes the tests slower, but it's hard to test otherwise that the code _didn't_ execute
await new Promise((r) => setTimeout(r, 300));
expect(screen.getByTestId("playground-result")).toHaveTextContent("2100"); // still the old value
await waitFor(() =>
expect(screen.getByTestId("playground-result")).toHaveTextContent("1600")
);
*/
});

View File

@ -0,0 +1,53 @@
import { render, screen } from "@testing-library/react";
import React from "react";
import "@testing-library/jest-dom";
import {
SquiggleChart,
SquiggleEditor,
SquigglePlayground,
} from "../src/index";
import { SqProject } from "@quri/squiggle-lang";
test("Chart logs nothing on render", async () => {
const { unmount } = render(<SquiggleChart code={"normal(0, 1)"} />);
unmount();
expect(console.log).not.toBeCalled();
expect(console.warn).not.toBeCalled();
expect(console.error).not.toBeCalled();
});
test("Editor logs nothing on render", async () => {
const { unmount } = render(<SquiggleEditor code={"normal(0, 1)"} />);
unmount();
expect(console.log).not.toBeCalled();
expect(console.warn).not.toBeCalled();
expect(console.error).not.toBeCalled();
});
test("Project dependencies work in editors", async () => {
const project = SqProject.create();
render(<SquiggleEditor code={"x = 1"} project={project} />);
const source = project.getSourceIds()[0];
const { container } = render(
<SquiggleEditor code={"x + 1"} project={project} continues={[source]} />
);
expect(container).toHaveTextContent("2");
});
test("Project dependencies work in playgrounds", async () => {
const project = SqProject.create();
project.setSource("depend", "x = 1");
render(
<SquigglePlayground
code={"x + 1"}
project={project}
continues={["depend"]}
/>
);
// We must await here because SquigglePlayground loads results asynchronously
expect(await screen.findByRole("status")).toHaveTextContent("2");
});

View File

@ -0,0 +1,39 @@
import { render } from "@testing-library/react";
import React from "react";
import "@testing-library/jest-dom";
import { SquiggleChart } from "../src/index";
import { SqProject } from "@quri/squiggle-lang";
test("Creates and cleans up source", async () => {
const project = SqProject.create();
const { unmount } = render(
<SquiggleChart code={"normal(0, 1)"} project={project} />
);
expect(project.getSourceIds().length).toBe(1);
const sourceId = project.getSourceIds()[0];
expect(project.getSource(sourceId)).toBe("normal(0, 1)");
unmount();
expect(project.getSourceIds().length).toBe(0);
expect(project.getSource(sourceId)).toBe(undefined);
});
test("Creates and cleans up source and imports", async () => {
const project = SqProject.create();
const { unmount } = render(
<SquiggleChart
code={"normal($x, 1)"}
project={project}
jsImports={{ x: 3 }}
/>
);
expect(project.getSourceIds().length).toBe(2);
unmount();
expect(project.getSourceIds()).toStrictEqual([]);
});

View File

@ -0,0 +1,8 @@
global.console = {
...console,
log: jest.fn(console.log),
debug: jest.fn(console.debug),
info: jest.fn(console.info),
warn: jest.fn(console.warn),
error: jest.fn(console.error),
};

View File

@ -0,0 +1,4 @@
{
"buildCommand": "cd ../.. && npx turbo run build --filter=@quri/squiggle-components",
"outputDirectory": "storybook-static"
}

View File

@ -23,3 +23,4 @@ coverage
.nyc_output/ .nyc_output/
src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_GeneratedParser.js src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_GeneratedParser.js
src/rescript/Reducer/Reducer_Peggy/helpers.js src/rescript/Reducer/Reducer_Peggy/helpers.js
src/rescript/ReducerProject/ReducerProject_IncludeParser.js

View File

@ -3,6 +3,8 @@ lib
*.bs.js *.bs.js
*.gen.tsx *.gen.tsx
.nyc_output/ .nyc_output/
_coverage/ coverage/
.cache/ .cache/
Reducer_Peggy_GeneratedParser.js Reducer_Peggy_GeneratedParser.js
ReducerProject_IncludeParser.js
src/rescript/Reducer/Reducer_Peggy/helpers.js

View File

@ -32,25 +32,29 @@ describe("dotSubtract", () => {
*/ */
Skip.test("mean of normal minus exponential (property)", () => { Skip.test("mean of normal minus exponential (property)", () => {
assert_( assert_(
property2(float_(), floatRange(1e-5, 1e5), (mean, rate) => { property2(
// We limit ourselves to stdev=1 so that the integral is trivial float_(),
let dotDifference = DistributionOperation.Constructors.pointwiseSubtract( floatRange(1e-5, 1e5),
~env, (mean, rate) => {
mkNormal(mean, 1.0), // We limit ourselves to stdev=1 so that the integral is trivial
mkExponential(rate), let dotDifference = DistributionOperation.Constructors.pointwiseSubtract(
) ~env,
let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference) mkNormal(mean, 1.0),
// according to algebra or random variables, mkExponential(rate),
let meanAnalytical =
mean -.
SymbolicDist.Exponential.mean({rate: rate})->E.R2.toExn(
"On trusted input this should never happen",
) )
switch meanResult { let meanResult = E.R2.bind(DistributionOperation.Constructors.mean(~env), dotDifference)
| Ok(meanValue) => abs_float(meanValue -. meanAnalytical) /. abs_float(meanValue) < 1e-2 // 1% relative error // according to algebra or random variables,
| Error(err) => err === DistributionTypes.OperationError(DivisionByZeroError) let meanAnalytical =
} mean -.
}), SymbolicDist.Exponential.mean({rate: rate})->E.R2.toExn(
"On trusted input this should never happen",
)
switch meanResult {
| Ok(meanValue) => abs_float(meanValue -. meanAnalytical) /. abs_float(meanValue) < 1e-2 // 1% relative error
| Error(err) => err === DistributionTypes.OperationError(DivisionByZeroError)
}
},
),
) )
pass pass
}) })

View File

@ -40,51 +40,60 @@ let algebraicPower = algebraicPower(~env)
describe("(Algebraic) addition of distributions", () => { describe("(Algebraic) addition of distributions", () => {
describe("mean", () => { describe("mean", () => {
test("normal(mean=5) + normal(mean=20)", () => { test(
normalDist5 "normal(mean=5) + normal(mean=20)",
->algebraicAdd(normalDist20) () => {
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean) normalDist5
->E.R2.fmap(run) ->algebraicAdd(normalDist20)
->E.R2.fmap(toFloat) ->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
->E.R.toExn("Expected float", _) ->E.R2.fmap(run)
->expect ->E.R2.fmap(toFloat)
->toBe(Some(2.5e1)) ->E.R.toExn("Expected float", _)
}) ->expect
->toBe(Some(2.5e1))
},
)
test("uniform(low=9, high=10) + beta(alpha=2, beta=5)", () => { test(
// let uniformMean = (9.0 +. 10.0) /. 2.0 "uniform(low=9, high=10) + beta(alpha=2, beta=5)",
// let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0) () => {
let received = // let uniformMean = (9.0 +. 10.0) /. 2.0
uniformDist // let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0)
->algebraicAdd(betaDist) let received =
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean) uniformDist
->E.R2.fmap(run) ->algebraicAdd(betaDist)
->E.R2.fmap(toFloat) ->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
->E.R.toExn("Expected float", _) ->E.R2.fmap(run)
switch received { ->E.R2.fmap(toFloat)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R.toExn("Expected float", _)
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. switch received {
// sometimes it works with ~digits=2. | None => "algebraicAdd has"->expect->toBe("failed")
| Some(x) => x->expect->toBeSoCloseTo(9.786831807237022, ~digits=1) // (uniformMean +. betaMean) // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
} // sometimes it works with ~digits=2.
}) | Some(x) => x->expect->toBeSoCloseTo(9.786831807237022, ~digits=1) // (uniformMean +. betaMean)
test("beta(alpha=2, beta=5) + uniform(low=9, high=10)", () => { }
// let uniformMean = (9.0 +. 10.0) /. 2.0 },
// let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0) )
let received = test(
betaDist "beta(alpha=2, beta=5) + uniform(low=9, high=10)",
->algebraicAdd(uniformDist) () => {
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean) // let uniformMean = (9.0 +. 10.0) /. 2.0
->E.R2.fmap(run) // let betaMean = 1.0 /. (1.0 +. 5.0 /. 2.0)
->E.R2.fmap(toFloat) let received =
->E.R.toExn("Expected float", _) betaDist
switch received { ->algebraicAdd(uniformDist)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. ->E.R2.fmap(run)
// sometimes it works with ~digits=2. ->E.R2.fmap(toFloat)
| Some(x) => x->expect->toBeSoCloseTo(9.784290207736126, ~digits=1) // (uniformMean +. betaMean) ->E.R.toExn("Expected float", _)
} switch received {
}) | None => "algebraicAdd has"->expect->toBe("failed")
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
// sometimes it works with ~digits=2.
| Some(x) => x->expect->toBeSoCloseTo(9.784290207736126, ~digits=1) // (uniformMean +. betaMean)
}
},
)
}) })
describe("pdf", () => { describe("pdf", () => {
// TEST IS WRONG. SEE STDEV ADDITION EXPRESSION. // TEST IS WRONG. SEE STDEV ADDITION EXPRESSION.
@ -122,247 +131,282 @@ describe("(Algebraic) addition of distributions", () => {
} }
}, },
) )
test("(normal(mean=10) + normal(mean=10)).pdf(1.9e1)", () => { test(
let received = "(normal(mean=10) + normal(mean=10)).pdf(1.9e1)",
normalDist20 () => {
->Ok let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1.9e1)) normalDist20
->E.R2.fmap(run) ->Ok
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1.9e1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
let calculated = ->E.R.toOption
normalDist10 ->E.O.flatten
->algebraicAdd(normalDist10) let calculated =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1.9e1)) normalDist10
->E.R2.fmap(run) ->algebraicAdd(normalDist10)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1.9e1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
switch received { ->E.R.toOption
| None => ->E.O.flatten
"this branch occurs when the dispatch to Jstat on trusted input fails." switch received {
->expect | None =>
->toBe("never") "this branch occurs when the dispatch to Jstat on trusted input fails."
| Some(x) => ->expect
switch calculated { ->toBe("never")
| None => "algebraicAdd has"->expect->toBe("failed") | Some(x) =>
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=1) switch calculated {
| None => "algebraicAdd has"->expect->toBe("failed")
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=1)
}
} }
} },
}) )
test("(uniform(low=9, high=10) + beta(alpha=2, beta=5)).pdf(10)", () => { test(
let received = "(uniform(low=9, high=10) + beta(alpha=2, beta=5)).pdf(10)",
uniformDist () => {
->algebraicAdd(betaDist) let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1)) uniformDist
->E.R2.fmap(run) ->algebraicAdd(betaDist)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1))
->E.R.toExn("Expected float", _) ->E.R2.fmap(run)
switch received { ->E.R2.fmap(toFloat)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R.toExn("Expected float", _)
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. switch received {
// sometimes it works with ~digits=4. | None => "algebraicAdd has"->expect->toBe("failed")
// This value was calculated by a python script // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
| Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0) // sometimes it works with ~digits=4.
} // This value was calculated by a python script
}) | Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0)
test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).pdf(10)", () => { }
let received = },
betaDist )
->algebraicAdd(uniformDist) test(
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1)) "(beta(alpha=2, beta=5) + uniform(low=9, high=10)).pdf(10)",
->E.R2.fmap(run) () => {
->E.R2.fmap(toFloat) let received =
->E.R.toExn("Expected float", _) betaDist
switch received { ->algebraicAdd(uniformDist)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1))
// This is nondeterministic. ->E.R2.fmap(run)
| Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0) ->E.R2.fmap(toFloat)
} ->E.R.toExn("Expected float", _)
}) switch received {
| None => "algebraicAdd has"->expect->toBe("failed")
// This is nondeterministic.
| Some(x) => x->expect->toBeSoCloseTo(0.979023, ~digits=0)
}
},
)
}) })
describe("cdf", () => { describe("cdf", () => {
testAll("(normal(mean=5) + normal(mean=5)).cdf (imprecise)", list{6e0, 8e0, 1e1, 1.2e1}, x => { testAll(
let received = "(normal(mean=5) + normal(mean=5)).cdf (imprecise)",
normalDist10 list{6e0, 8e0, 1e1, 1.2e1},
->Ok x => {
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, x)) let received =
->E.R2.fmap(run) normalDist10
->E.R2.fmap(toFloat) ->Ok
->E.R.toOption ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, x))
->E.O.flatten ->E.R2.fmap(run)
let calculated = ->E.R2.fmap(toFloat)
normalDist5 ->E.R.toOption
->algebraicAdd(normalDist5) ->E.O.flatten
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, x)) let calculated =
->E.R2.fmap(run) normalDist5
->E.R2.fmap(toFloat) ->algebraicAdd(normalDist5)
->E.R.toOption ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, x))
->E.O.flatten ->E.R2.fmap(run)
->E.R2.fmap(toFloat)
->E.R.toOption
->E.O.flatten
switch received { switch received {
| None => | None =>
"this branch occurs when the dispatch to Jstat on trusted input fails." "this branch occurs when the dispatch to Jstat on trusted input fails."
->expect ->expect
->toBe("never") ->toBe("never")
| Some(x) => | Some(x) =>
switch calculated { switch calculated {
| None => "algebraicAdd has"->expect->toBe("failed") | None => "algebraicAdd has"->expect->toBe("failed")
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=0) | Some(y) => x->expect->toBeSoCloseTo(y, ~digits=0)
}
} }
} },
}) )
test("(normal(mean=10) + normal(mean=10)).cdf(1.25e1)", () => { test(
let received = "(normal(mean=10) + normal(mean=10)).cdf(1.25e1)",
normalDist20 () => {
->Ok let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1.25e1)) normalDist20
->E.R2.fmap(run) ->Ok
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1.25e1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
let calculated = ->E.R.toOption
normalDist10 ->E.O.flatten
->algebraicAdd(normalDist10) let calculated =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1.25e1)) normalDist10
->E.R2.fmap(run) ->algebraicAdd(normalDist10)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1.25e1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
switch received { ->E.R.toOption
| None => ->E.O.flatten
"this branch occurs when the dispatch to Jstat on trusted input fails." switch received {
->expect | None =>
->toBe("never") "this branch occurs when the dispatch to Jstat on trusted input fails."
| Some(x) => ->expect
switch calculated { ->toBe("never")
| None => "algebraicAdd has"->expect->toBe("failed") | Some(x) =>
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=2) switch calculated {
| None => "algebraicAdd has"->expect->toBe("failed")
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=2)
}
} }
} },
}) )
test("(uniform(low=9, high=10) + beta(alpha=2, beta=5)).cdf(10)", () => { test(
let received = "(uniform(low=9, high=10) + beta(alpha=2, beta=5)).cdf(10)",
uniformDist () => {
->algebraicAdd(betaDist) let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1)) uniformDist
->E.R2.fmap(run) ->algebraicAdd(betaDist)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1))
->E.R.toExn("Expected float", _) ->E.R2.fmap(run)
switch received { ->E.R2.fmap(toFloat)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R.toExn("Expected float", _)
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. switch received {
// The value was calculated externally using a python script | None => "algebraicAdd has"->expect->toBe("failed")
| Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1) // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
} // The value was calculated externally using a python script
}) | Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1)
test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).cdf(10)", () => { }
let received = },
betaDist )
->algebraicAdd(uniformDist) test(
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1)) "(beta(alpha=2, beta=5) + uniform(low=9, high=10)).cdf(10)",
->E.R2.fmap(run) () => {
->E.R2.fmap(toFloat) let received =
->E.R.toExn("Expected float", _) betaDist
switch received { ->algebraicAdd(uniformDist)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1))
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. ->E.R2.fmap(run)
// The value was calculated externally using a python script ->E.R2.fmap(toFloat)
| Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1) ->E.R.toExn("Expected float", _)
} switch received {
}) | None => "algebraicAdd has"->expect->toBe("failed")
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
// The value was calculated externally using a python script
| Some(x) => x->expect->toBeSoCloseTo(0.71148, ~digits=1)
}
},
)
}) })
describe("inv", () => { describe("inv", () => {
testAll("(normal(mean=5) + normal(mean=5)).inv (imprecise)", list{5e-2, 4.2e-3, 9e-3}, x => { testAll(
let received = "(normal(mean=5) + normal(mean=5)).inv (imprecise)",
normalDist10 list{5e-2, 4.2e-3, 9e-3},
->Ok x => {
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, x)) let received =
->E.R2.fmap(run) normalDist10
->E.R2.fmap(toFloat) ->Ok
->E.R.toOption ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, x))
->E.O.flatten ->E.R2.fmap(run)
let calculated = ->E.R2.fmap(toFloat)
normalDist5 ->E.R.toOption
->algebraicAdd(normalDist5) ->E.O.flatten
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, x)) let calculated =
->E.R2.fmap(run) normalDist5
->E.R2.fmap(toFloat) ->algebraicAdd(normalDist5)
->E.R.toOption ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, x))
->E.O.flatten ->E.R2.fmap(run)
->E.R2.fmap(toFloat)
->E.R.toOption
->E.O.flatten
switch received { switch received {
| None => | None =>
"this branch occurs when the dispatch to Jstat on trusted input fails." "this branch occurs when the dispatch to Jstat on trusted input fails."
->expect ->expect
->toBe("never") ->toBe("never")
| Some(x) => | Some(x) =>
switch calculated { switch calculated {
| None => "algebraicAdd has"->expect->toBe("failed") | None => "algebraicAdd has"->expect->toBe("failed")
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=-1) | Some(y) => x->expect->toBeSoCloseTo(y, ~digits=-1)
}
} }
} },
}) )
test("(normal(mean=10) + normal(mean=10)).inv(1e-1)", () => { test(
let received = "(normal(mean=10) + normal(mean=10)).inv(1e-1)",
normalDist20 () => {
->Ok let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 1e-1)) normalDist20
->E.R2.fmap(run) ->Ok
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 1e-1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
let calculated = ->E.R.toOption
normalDist10 ->E.O.flatten
->algebraicAdd(normalDist10) let calculated =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 1e-1)) normalDist10
->E.R2.fmap(run) ->algebraicAdd(normalDist10)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 1e-1))
->E.R.toOption ->E.R2.fmap(run)
->E.O.flatten ->E.R2.fmap(toFloat)
switch received { ->E.R.toOption
| None => ->E.O.flatten
"this branch occurs when the dispatch to Jstat on trusted input fails." switch received {
->expect | None =>
->toBe("never") "this branch occurs when the dispatch to Jstat on trusted input fails."
| Some(x) => ->expect
switch calculated { ->toBe("never")
| None => "algebraicAdd has"->expect->toBe("failed") | Some(x) =>
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=-1) switch calculated {
| None => "algebraicAdd has"->expect->toBe("failed")
| Some(y) => x->expect->toBeSoCloseTo(y, ~digits=-1)
}
} }
} },
}) )
test("(uniform(low=9, high=10) + beta(alpha=2, beta=5)).inv(2e-2)", () => { test(
let received = "(uniform(low=9, high=10) + beta(alpha=2, beta=5)).inv(2e-2)",
uniformDist () => {
->algebraicAdd(betaDist) let received =
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2)) uniformDist
->E.R2.fmap(run) ->algebraicAdd(betaDist)
->E.R2.fmap(toFloat) ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2))
->E.R.toExn("Expected float", _) ->E.R2.fmap(run)
switch received { ->E.R2.fmap(toFloat)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R.toExn("Expected float", _)
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. switch received {
// sometimes it works with ~digits=2. | None => "algebraicAdd has"->expect->toBe("failed")
| Some(x) => x->expect->toBeSoCloseTo(9.179319623146968, ~digits=0) // This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
} // sometimes it works with ~digits=2.
}) | Some(x) => x->expect->toBeSoCloseTo(9.179319623146968, ~digits=0)
test("(beta(alpha=2, beta=5) + uniform(low=9, high=10)).inv(2e-2)", () => { }
let received = },
betaDist )
->algebraicAdd(uniformDist) test(
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2)) "(beta(alpha=2, beta=5) + uniform(low=9, high=10)).inv(2e-2)",
->E.R2.fmap(run) () => {
->E.R2.fmap(toFloat) let received =
->E.R.toExn("Expected float", _) betaDist
switch received { ->algebraicAdd(uniformDist)
| None => "algebraicAdd has"->expect->toBe("failed") ->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2))
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad. ->E.R2.fmap(run)
// sometimes it works with ~digits=2. ->E.R2.fmap(toFloat)
| Some(x) => x->expect->toBeSoCloseTo(9.190872365862756, ~digits=0) ->E.R.toExn("Expected float", _)
} switch received {
}) | None => "algebraicAdd has"->expect->toBe("failed")
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
// sometimes it works with ~digits=2.
| Some(x) => x->expect->toBeSoCloseTo(9.190872365862756, ~digits=0)
}
},
)
}) })
}) })

View File

@ -3,7 +3,7 @@ This is the most basic file in our invariants family of tests.
Validate that the addition of means equals the mean of the addition, similar for subtraction and multiplication. Validate that the addition of means equals the mean of the addition, similar for subtraction and multiplication.
Details in https://develop--squiggle-documentation.netlify.app/docs/internal/invariants/ Details in https://squiggle-language.com/docs/internal/invariants/
Note: epsilon of 1e3 means the invariants are, in general, not being satisfied. Note: epsilon of 1e3 means the invariants are, in general, not being satisfied.
*/ */
@ -87,14 +87,22 @@ describe("Means are invariant", () => {
let testAddInvariant = (t1, t2) => let testAddInvariant = (t1, t2) =>
E.R.liftM2(testAdditionMean, t1, t2)->E.R.toExn("Means were not invariant", _) E.R.liftM2(testAdditionMean, t1, t2)->E.R.toExn("Means were not invariant", _)
testAll("with two of the same distribution", distributions, dist => { testAll(
testAddInvariant(dist, dist) "with two of the same distribution",
}) distributions,
dist => {
testAddInvariant(dist, dist)
},
)
testAll("with two different distributions", pairsOfDifferentDistributions, dists => { testAll(
let (dist1, dist2) = dists "with two different distributions",
testAddInvariant(dist1, dist2) pairsOfDifferentDistributions,
}) dists => {
let (dist1, dist2) = dists
testAddInvariant(dist1, dist2)
},
)
testAll( testAll(
"with two different distributions in swapped order", "with two different distributions in swapped order",
@ -116,14 +124,22 @@ describe("Means are invariant", () => {
let testSubtractInvariant = (t1, t2) => let testSubtractInvariant = (t1, t2) =>
E.R.liftM2(testSubtractionMean, t1, t2)->E.R.toExn("Means were not invariant", _) E.R.liftM2(testSubtractionMean, t1, t2)->E.R.toExn("Means were not invariant", _)
testAll("with two of the same distribution", distributions, dist => { testAll(
testSubtractInvariant(dist, dist) "with two of the same distribution",
}) distributions,
dist => {
testSubtractInvariant(dist, dist)
},
)
testAll("with two different distributions", pairsOfDifferentDistributions, dists => { testAll(
let (dist1, dist2) = dists "with two different distributions",
testSubtractInvariant(dist1, dist2) pairsOfDifferentDistributions,
}) dists => {
let (dist1, dist2) = dists
testSubtractInvariant(dist1, dist2)
},
)
testAll( testAll(
"with two different distributions in swapped order", "with two different distributions in swapped order",
@ -145,14 +161,22 @@ describe("Means are invariant", () => {
let testMultiplicationInvariant = (t1, t2) => let testMultiplicationInvariant = (t1, t2) =>
E.R.liftM2(testMultiplicationMean, t1, t2)->E.R.toExn("Means were not invariant", _) E.R.liftM2(testMultiplicationMean, t1, t2)->E.R.toExn("Means were not invariant", _)
testAll("with two of the same distribution", distributions, dist => { testAll(
testMultiplicationInvariant(dist, dist) "with two of the same distribution",
}) distributions,
dist => {
testMultiplicationInvariant(dist, dist)
},
)
testAll("with two different distributions", pairsOfDifferentDistributions, dists => { testAll(
let (dist1, dist2) = dists "with two different distributions",
testMultiplicationInvariant(dist1, dist2) pairsOfDifferentDistributions,
}) dists => {
let (dist1, dist2) = dists
testMultiplicationInvariant(dist1, dist2)
},
)
testAll( testAll(
"with two different distributions in swapped order", "with two different distributions in swapped order",

View File

@ -17,10 +17,9 @@ describe("klDivergence: continuous -> continuous -> float", () => {
let answer = let answer =
uniformMakeR(lowAnswer, highAnswer)->E.R2.errMap(s => DistributionTypes.ArgumentError(s)) uniformMakeR(lowAnswer, highAnswer)->E.R2.errMap(s => DistributionTypes.ArgumentError(s))
let prediction = let prediction =
uniformMakeR( uniformMakeR(lowPrediction, highPrediction)->E.R2.errMap(
lowPrediction, s => DistributionTypes.ArgumentError(s),
highPrediction, )
)->E.R2.errMap(s => DistributionTypes.ArgumentError(s))
// integral along the support of the answer of answer.pdf(x) times log of prediction.pdf(x) divided by answer.pdf(x) dx // integral along the support of the answer of answer.pdf(x) times log of prediction.pdf(x) divided by answer.pdf(x) dx
let analyticalKl = Js.Math.log((highPrediction -. lowPrediction) /. (highAnswer -. lowAnswer)) let analyticalKl = Js.Math.log((highPrediction -. lowPrediction) /. (highAnswer -. lowAnswer))
let kl = E.R.liftJoin2(klDivergence, prediction, answer) let kl = E.R.liftJoin2(klDivergence, prediction, answer)
@ -183,9 +182,9 @@ describe("combineAlongSupportOfSecondArgument0", () => {
let answer = let answer =
uniformMakeR(lowAnswer, highAnswer)->E.R2.errMap(s => DistributionTypes.ArgumentError(s)) uniformMakeR(lowAnswer, highAnswer)->E.R2.errMap(s => DistributionTypes.ArgumentError(s))
let prediction = let prediction =
uniformMakeR(lowPrediction, highPrediction)->E.R2.errMap(s => DistributionTypes.ArgumentError( uniformMakeR(lowPrediction, highPrediction)->E.R2.errMap(
s, s => DistributionTypes.ArgumentError(s),
)) )
let answerWrapped = E.R.fmap(a => run(FromDist(#ToDist(ToPointSet), a)), answer) let answerWrapped = E.R.fmap(a => run(FromDist(#ToDist(ToPointSet), a)), answer)
let predictionWrapped = E.R.fmap(a => run(FromDist(#ToDist(ToPointSet), a)), prediction) let predictionWrapped = E.R.fmap(a => run(FromDist(#ToDist(ToPointSet), a)), prediction)

View File

@ -3,7 +3,7 @@ open Expect
open TestHelpers open TestHelpers
// TODO: use Normal.make (but preferably after teh new validation dispatch is in) // TODO: use Normal.make (but preferably after teh new validation dispatch is in)
let mkNormal = (mean, stdev) => DistributionTypes.Symbolic(#Normal({mean: mean, stdev: stdev})) let mkNormal = (mean, stdev) => DistributionTypes.Symbolic(#Normal({mean, stdev}))
describe("(Symbolic) normalize", () => { describe("(Symbolic) normalize", () => {
testAll("has no impact on normal distributions", list{-1e8, -1e-2, 0.0, 1e-4, 1e16}, mean => { testAll("has no impact on normal distributions", list{-1e8, -1e-2, 0.0, 1e-4, 1e16}, mean => {
@ -47,10 +47,7 @@ describe("(Symbolic) mean", () => {
tup => { tup => {
let (low, medium, high) = tup let (low, medium, high) = tup
let meanValue = run( let meanValue = run(
FromDist( FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Triangular({low, medium, high}))),
#ToFloat(#Mean),
DistributionTypes.Symbolic(#Triangular({low: low, medium: medium, high: high})),
),
) )
meanValue->unpackFloat->expect->toBeCloseTo((low +. medium +. high) /. 3.0) // https://www.statology.org/triangular-distribution/ meanValue->unpackFloat->expect->toBeCloseTo((low +. medium +. high) /. 3.0) // https://www.statology.org/triangular-distribution/
}, },
@ -63,7 +60,7 @@ describe("(Symbolic) mean", () => {
tup => { tup => {
let (alpha, beta) = tup let (alpha, beta) = tup
let meanValue = run( let meanValue = run(
FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Beta({alpha: alpha, beta: beta}))), FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Beta({alpha, beta}))),
) )
meanValue->unpackFloat->expect->toBeCloseTo(1.0 /. (1.0 +. beta /. alpha)) // https://en.wikipedia.org/wiki/Beta_distribution#Mean meanValue->unpackFloat->expect->toBeCloseTo(1.0 /. (1.0 +. beta /. alpha)) // https://en.wikipedia.org/wiki/Beta_distribution#Mean
}, },
@ -84,8 +81,8 @@ describe("(Symbolic) mean", () => {
let (mean, stdev) = tup let (mean, stdev) = tup
let betaDistribution = SymbolicDist.Beta.fromMeanAndStdev(mean, stdev) let betaDistribution = SymbolicDist.Beta.fromMeanAndStdev(mean, stdev)
let meanValue = let meanValue =
betaDistribution->E.R2.fmap(d => betaDistribution->E.R2.fmap(
run(FromDist(#ToFloat(#Mean), d->DistributionTypes.Symbolic)) d => run(FromDist(#ToFloat(#Mean), d->DistributionTypes.Symbolic)),
) )
switch meanValue { switch meanValue {
| Ok(value) => value->unpackFloat->expect->toBeCloseTo(mean) | Ok(value) => value->unpackFloat->expect->toBeCloseTo(mean)
@ -100,7 +97,7 @@ describe("(Symbolic) mean", () => {
tup => { tup => {
let (mu, sigma) = tup let (mu, sigma) = tup
let meanValue = run( let meanValue = run(
FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Lognormal({mu: mu, sigma: sigma}))), FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Lognormal({mu, sigma}))),
) )
meanValue->unpackFloat->expect->toBeCloseTo(Js.Math.exp(mu +. sigma ** 2.0 /. 2.0)) // https://brilliant.org/wiki/log-normal-distribution/ meanValue->unpackFloat->expect->toBeCloseTo(Js.Math.exp(mu +. sigma ** 2.0 /. 2.0)) // https://brilliant.org/wiki/log-normal-distribution/
}, },
@ -112,7 +109,7 @@ describe("(Symbolic) mean", () => {
tup => { tup => {
let (low, high) = tup let (low, high) = tup
let meanValue = run( let meanValue = run(
FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Uniform({low: low, high: high}))), FromDist(#ToFloat(#Mean), DistributionTypes.Symbolic(#Uniform({low, high}))),
) )
meanValue->unpackFloat->expect->toBeCloseTo((low +. high) /. 2.0) // https://en.wikipedia.org/wiki/Continuous_uniform_distribution#Moments meanValue->unpackFloat->expect->toBeCloseTo((low +. high) /. 2.0) // https://en.wikipedia.org/wiki/Continuous_uniform_distribution#Moments
}, },

View File

@ -0,0 +1,21 @@
open Jest
open TestHelpers
describe("E.A.getByFmap", () => {
makeTest("Empty list returns None", E.A.getByFmap([], x => x + 1, x => mod(x, 2) == 0), None)
makeTest(
"Never predicate returns None",
E.A.getByFmap([1, 2, 3, 4, 5, 6], x => x + 1, _ => false),
None,
)
makeTest(
"function evaluates",
E.A.getByFmap([1, 1, 1, 1, 1, 1, 1, 2, 1, 1], x => 3 * x, x => x > 4),
Some(6),
)
makeTest(
"always predicate returns fn(fst(a))",
E.A.getByFmap([0, 1, 2, 3, 4, 5, 6], x => 10 + x, _ => true),
Some(10),
)
})

View File

@ -9,22 +9,28 @@ let prepareInputs = (ar, minWeight) =>
describe("Continuous and discrete splits", () => { describe("Continuous and discrete splits", () => {
makeTest( makeTest(
"is empty, with no common elements", "is empty, with no common elements",
prepareInputs([1.432, 1.33455, 2.0], 2), prepareInputs([1.33455, 1.432, 2.0], 2),
([1.33455, 1.432, 2.0], []), ([1.33455, 1.432, 2.0], []),
) )
makeTest( makeTest(
"only stores 3.5 as discrete when minWeight is 3", "only stores 3.5 as discrete when minWeight is 3",
prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 3), prepareInputs([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], 3),
([1.33455, 1.432, 2.0, 2.0], [(3.5, 3.0)]), ([1.33455, 1.432, 2.0, 2.0], [(3.5, 3.0)]),
) )
makeTest( makeTest(
"doesn't store 3.5 as discrete when minWeight is 5", "doesn't store 3.5 as discrete when minWeight is 5",
prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 5), prepareInputs([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], 5),
([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], []), ([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], []),
) )
makeTest(
"more general test",
prepareInputs([10., 10., 11., 11., 11., 12., 13., 13., 13., 13., 13., 14.], 3),
([10., 10., 12., 14.], [(11., 3.), (13., 5.)]),
)
let makeDuplicatedArray = count => { let makeDuplicatedArray = count => {
let arr = Belt.Array.range(1, count) |> E.A.fmap(float_of_int) let arr = Belt.Array.range(1, count) |> E.A.fmap(float_of_int)
let sorted = arr |> Belt.SortArray.stableSortBy(_, compare) let sorted = arr |> Belt.SortArray.stableSortBy(_, compare)

View File

@ -1,20 +0,0 @@
open Jest
open Expect
let makeTest = (~only=false, str, item1, item2) =>
only
? Only.test(str, () => expect(item1)->toEqual(item2))
: test(str, () => expect(item1)->toEqual(item2))
describe("Lodash", () =>
describe("Lodash", () => {
makeTest("min", Lodash.min([1, 3, 4]), 1)
makeTest("max", Lodash.max([1, 3, 4]), 4)
makeTest("uniq", Lodash.uniq([1, 3, 4, 4]), [1, 3, 4])
makeTest(
"countBy",
Lodash.countBy([1, 3, 4, 4], r => r),
Js.Dict.fromArray([("1", 1), ("3", 1), ("4", 2)]),
)
})
)

View File

@ -0,0 +1,50 @@
@@warning("-44")
module Bindings = Reducer_Bindings
module Namespace = Reducer_Namespace
open Jest
open Expect
open Expect.Operators
describe("Bindings", () => {
let value = Reducer_T.IEvNumber(1967.0)
let bindings = Bindings.make()->Bindings.set("value", value)
test("get", () => {
expect(bindings->Bindings.get("value")) == Some(value)
})
test("get nonexisting value", () => {
expect(bindings->Bindings.get("nosuchvalue")) == None
})
test("get on extended", () => {
expect(bindings->Bindings.extend->Bindings.get("value")) == Some(value)
})
test("locals", () => {
expect(bindings->Bindings.locals->Namespace.get("value")) == Some(value)
})
test("locals on extendeed", () => {
expect(bindings->Bindings.extend->Bindings.locals->Namespace.get("value")) == None
})
describe("extend", () => {
let value2 = Reducer_T.IEvNumber(5.)
let extendedBindings = bindings->Bindings.extend->Bindings.set("value", value2)
test(
"get on extended",
() => {
expect(extendedBindings->Bindings.get("value")) == Some(value2)
},
)
test(
"get on original",
() => {
expect(bindings->Bindings.get("value")) == Some(value)
},
)
})
})

View File

@ -1,4 +0,0 @@
open Jest
open Expect
test("todo", () => expect("1")->toBe("1"))

View File

@ -1,146 +0,0 @@
open Jest
// open Expect
open Reducer_Expression_ExpressionBuilder
open Reducer_TestMacroHelpers
module ExpressionT = Reducer_Expression_T
let exampleExpression = eNumber(1.)
let exampleExpressionY = eSymbol("y")
let exampleStatementY = eLetStatement("y", eNumber(1.))
let exampleStatementX = eLetStatement("y", eSymbol("x"))
let exampleStatementZ = eLetStatement("z", eSymbol("y"))
// If it is not a macro then it is not expanded
testMacro([], exampleExpression, "Ok(1)")
describe("bindStatement", () => {
// A statement is bound by the bindings created by the previous statement
testMacro(
[],
eBindStatement(eBindings([]), exampleStatementY),
"Ok((:$_setBindings_$ @{} :y 1) context: @{})",
)
// Then it answers the bindings for the next statement when reduced
testMacroEval([], eBindStatement(eBindings([]), exampleStatementY), "Ok(@{y: 1})")
// Now let's feed a binding to see what happens
testMacro(
[],
eBindStatement(eBindings([("x", IEvNumber(2.))]), exampleStatementX),
"Ok((:$_setBindings_$ @{x: 2} :y 2) context: @{x: 2})",
)
// An expression does not return a binding, thus error
testMacro([], eBindStatement(eBindings([]), exampleExpression), "Assignment expected")
// When bindings from previous statement are missing the context is injected. This must be the first statement of a block
testMacro(
[("z", IEvNumber(99.))],
eBindStatementDefault(exampleStatementY),
"Ok((:$_setBindings_$ @{z: 99} :y 1) context: @{z: 99})",
)
})
describe("bindExpression", () => {
// x is simply bound in the expression
testMacro(
[],
eBindExpression(eBindings([("x", IEvNumber(2.))]), eSymbol("x")),
"Ok(2 context: @{x: 2})",
)
// When an let statement is the end expression then bindings are returned
testMacro(
[],
eBindExpression(eBindings([("x", IEvNumber(2.))]), exampleStatementY),
"Ok((:$_exportBindings_$ (:$_setBindings_$ @{x: 2} :y 1)) context: @{x: 2})",
)
// Now let's reduce that expression
testMacroEval(
[],
eBindExpression(eBindings([("x", IEvNumber(2.))]), exampleStatementY),
"Ok(@{x: 2,y: 1})",
)
// When bindings are missing the context is injected. This must be the first and last statement of a block
testMacroEval(
[("z", IEvNumber(99.))],
eBindExpressionDefault(exampleStatementY),
"Ok(@{y: 1,z: 99})",
)
})
describe("block", () => {
// Block with a single expression
testMacro([], eBlock(list{exampleExpression}), "Ok((:$$_bindExpression_$$ 1))")
testMacroEval([], eBlock(list{exampleExpression}), "Ok(1)")
// Block with a single statement
testMacro([], eBlock(list{exampleStatementY}), "Ok((:$$_bindExpression_$$ (:$_let_$ :y 1)))")
testMacroEval([], eBlock(list{exampleStatementY}), "Ok(@{y: 1})")
// Block with a statement and an expression
testMacro(
[],
eBlock(list{exampleStatementY, exampleExpressionY}),
"Ok((:$$_bindExpression_$$ (:$$_bindStatement_$$ (:$_let_$ :y 1)) :y))",
)
testMacroEval([], eBlock(list{exampleStatementY, exampleExpressionY}), "Ok(1)")
// Block with a statement and another statement
testMacro(
[],
eBlock(list{exampleStatementY, exampleStatementZ}),
"Ok((:$$_bindExpression_$$ (:$$_bindStatement_$$ (:$_let_$ :y 1)) (:$_let_$ :z :y)))",
)
testMacroEval([], eBlock(list{exampleStatementY, exampleStatementZ}), "Ok(@{y: 1,z: 1})")
// Block inside a block
testMacro([], eBlock(list{eBlock(list{exampleExpression})}), "Ok((:$$_bindExpression_$$ {1}))")
testMacroEval([], eBlock(list{eBlock(list{exampleExpression})}), "Ok(1)")
// Block assigned to a variable
testMacro(
[],
eBlock(list{eLetStatement("z", eBlock(list{eBlock(list{exampleExpressionY})}))}),
"Ok((:$$_bindExpression_$$ (:$_let_$ :z {{:y}})))",
)
testMacroEval(
[],
eBlock(list{eLetStatement("z", eBlock(list{eBlock(list{exampleExpressionY})}))}),
"Ok(@{z: :y})",
)
// Empty block
testMacro([], eBlock(list{}), "Ok(:undefined block)") //TODO: should be an error
// :$$_block_$$ (:$$_block_$$ (:$_let_$ :y (:add :x 1)) :y)"
testMacro(
[],
eBlock(list{
eBlock(list{
eLetStatement("y", eFunction("add", list{eSymbol("x"), eNumber(1.)})),
eSymbol("y"),
}),
}),
"Ok((:$$_bindExpression_$$ {(:$_let_$ :y (:add :x 1)); :y}))",
)
testMacroEval(
[("x", IEvNumber(1.))],
eBlock(list{
eBlock(list{
eLetStatement("y", eFunction("add", list{eSymbol("x"), eNumber(1.)})),
eSymbol("y"),
}),
}),
"Ok(2)",
)
})
describe("lambda", () => {
// assign a lambda to a variable
let lambdaExpression = eFunction("$$_lambda_$$", list{eArrayString(["y"]), exampleExpressionY})
testMacro([], lambdaExpression, "Ok(lambda(y=>internal code))")
// call a lambda
let callLambdaExpression = list{lambdaExpression, eNumber(1.)}->ExpressionT.EList
testMacro([], callLambdaExpression, "Ok(((:$$_lambda_$$ [y] :y) 1))")
testMacroEval([], callLambdaExpression, "Ok(1)")
// Parameters shadow the outer scope
testMacroEval([("y", IEvNumber(666.))], callLambdaExpression, "Ok(1)")
// When not shadowed by the parameters, the outer scope variables are available
let lambdaExpression = eFunction(
"$$_lambda_$$",
list{eArrayString(["z"]), eFunction("add", list{eSymbol("y"), eSymbol("z")})},
)
let callLambdaExpression = eList(list{lambdaExpression, eNumber(1.)})
testMacroEval([("y", IEvNumber(666.))], callLambdaExpression, "Ok(667)")
})

View File

@ -1,37 +0,0 @@
module ExpressionValue = ReducerInterface.ExternalExpressionValue
open Jest
open Expect
let expectEvalToBe = (expr: string, answer: string) =>
Reducer.evaluate(expr)->ExpressionValue.toStringResult->expect->toBe(answer)
let testEval = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer))
describe("builtin", () => {
// All MathJs operators and functions are available for string, number and boolean
// .e.g + - / * > >= < <= == /= not and or
// See https://mathjs.org/docs/expressions/syntax.html
// See https://mathjs.org/docs/reference/functions.html
testEval("-1", "Ok(-1)")
testEval("1-1", "Ok(0)")
testEval("2>1", "Ok(true)")
testEval("concat('a','b')", "Ok('ab')")
})
describe("builtin exception", () => {
//It's a pity that MathJs does not return error position
test("MathJs Exception", () =>
expectEvalToBe("testZadanga(1)", "Error(JS Exception: Error: Undefined function testZadanga)")
)
})
describe("error reporting from collection functions", () => {
testEval("arr=[1,2,3]; map(arr, {|x| x*2})", "Ok([2,4,6])")
testEval(
"arr = [normal(3,2)]; map(arr, zarathsuzaWasHere)",
"Error(zarathsuzaWasHere is not defined)",
)
// FIXME: returns "Error(Function not found: map(Array,Symbol))"
// Actually this error is correct but not informative
})

View File

@ -1,22 +0,0 @@
// Reducer_Helpers
module ErrorValue = Reducer_ErrorValue
module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
module Bindings = Reducer_Bindings
let removeDefaultsInternal = (iev: InternalExpressionValue.t) => {
switch iev {
| InternalExpressionValue.IEvBindings(nameSpace) =>
Bindings.removeOther(
nameSpace,
ReducerInterface.StdLib.internalStdLib,
)->InternalExpressionValue.IEvBindings
| value => value
}
}
let removeDefaultsExternal = (ev: ExternalExpressionValue.t): ExternalExpressionValue.t =>
ev->InternalExpressionValue.toInternal->removeDefaultsInternal->InternalExpressionValue.toExternal
let rRemoveDefaultsInternal = r => Belt.Result.map(r, removeDefaultsInternal)
let rRemoveDefaultsExternal = r => Belt.Result.map(r, removeDefaultsExternal)

View File

@ -1,31 +0,0 @@
module MathJs = Reducer_MathJs
module ErrorValue = Reducer.ErrorValue
open Jest
open ExpectJs
describe("eval", () => {
test("Number", () => expect(MathJs.Eval.eval("1"))->toEqual(Ok(IEvNumber(1.))))
test("Number expr", () => expect(MathJs.Eval.eval("1-1"))->toEqual(Ok(IEvNumber(0.))))
test("String", () => expect(MathJs.Eval.eval("'hello'"))->toEqual(Ok(IEvString("hello"))))
test("String expr", () =>
expect(MathJs.Eval.eval("concat('hello ','world')"))->toEqual(Ok(IEvString("hello world")))
)
test("Boolean", () => expect(MathJs.Eval.eval("true"))->toEqual(Ok(IEvBool(true))))
test("Boolean expr", () => expect(MathJs.Eval.eval("2>1"))->toEqual(Ok(IEvBool(true))))
})
describe("errors", () => {
// All those errors propagete up and are returned by the resolver
test("unknown function", () =>
expect(MathJs.Eval.eval("testZadanga()"))->toEqual(
Error(ErrorValue.REJavaScriptExn(Some("Undefined function testZadanga"), Some("Error"))),
)
)
test("unknown answer type", () =>
expect(MathJs.Eval.eval("1+1i"))->toEqual(
Error(ErrorValue.RETodo("Unhandled MathJs literal type: object")),
)
)
})

View File

@ -0,0 +1,62 @@
@@warning("-44")
module Namespace = Reducer_Namespace
open Jest
open Expect
open Expect.Operators
let makeValue = (v: float) => v->Reducer_T.IEvNumber
describe("Namespace", () => {
let value = makeValue(5.)
let v2 = makeValue(2.)
let ns = Namespace.make()->Namespace.set("value", value)
test("get", () => {
expect(ns->Namespace.get("value")) == Some(value)
})
test("get nonexisting value", () => {
expect(ns->Namespace.get("nosuchvalue")) == None
})
test("set", () => {
let ns2 = ns->Namespace.set("v2", v2)
expect(ns2->Namespace.get("v2")) == Some(v2)
})
test("immutable", () => {
let _ = ns->Namespace.set("v2", Reducer_T.IEvNumber(2.))
expect(ns->Namespace.get("v2")) == None
})
describe("merge many", () => {
let x1 = makeValue(10.)
let x2 = makeValue(20.)
let x3 = makeValue(30.)
let x4 = makeValue(40.)
let ns1 = Namespace.make()->Namespace.set("x1", x1)->Namespace.set("x2", x2)
let ns2 = Namespace.make()->Namespace.set("x3", x3)->Namespace.set("x4", x4)
let nsMerged = Namespace.mergeMany([ns, ns1, ns2])
test(
"merge many 1",
() => {
expect(nsMerged->Namespace.get("x1")) == Some(x1)
},
)
test(
"merge many 2",
() => {
expect(nsMerged->Namespace.get("x4")) == Some(x4)
},
)
test(
"merge many 3",
() => {
expect(nsMerged->Namespace.get("value")) == Some(value)
},
)
})
})

View File

@ -14,47 +14,46 @@ describe("Peggy parse", () => {
}) })
describe("literals operators parenthesis", () => { describe("literals operators parenthesis", () => {
// Note that there is always an outer block. Otherwise, external bindings are ignrored at the first statement
testParse("1", "{1}") testParse("1", "{1}")
testParse("'hello'", "{'hello'}") testParse("'hello'", "{'hello'}")
testParse("true", "{true}") testParse("true", "{true}")
testParse("1+2", "{(::add 1 2)}") testParse("1+2", "{(:add 1 2)}")
testParse("add(1,2)", "{(::add 1 2)}") testParse("add(1,2)", "{(:add 1 2)}")
testParse("(1)", "{1}") testParse("(1)", "{1}")
testParse("(1+2)", "{(::add 1 2)}") testParse("(1+2)", "{(:add 1 2)}")
}) })
describe("unary", () => { describe("unary", () => {
testParse("-1", "{(::unaryMinus 1)}") testParse("-1", "{(:unaryMinus 1)}")
testParse("!true", "{(::not true)}") testParse("!true", "{(:not true)}")
testParse("1 + -1", "{(::add 1 (::unaryMinus 1))}") testParse("1 + -1", "{(:add 1 (:unaryMinus 1))}")
testParse("-a[0]", "{(::unaryMinus (::$_atIndex_$ :a 0))}") testParse("-a[0]", "{(:unaryMinus (:$_atIndex_$ :a 0))}")
testParse("!a[0]", "{(::not (::$_atIndex_$ :a 0))}") testParse("!a[0]", "{(:not (:$_atIndex_$ :a 0))}")
}) })
describe("multiplicative", () => { describe("multiplicative", () => {
testParse("1 * 2", "{(::multiply 1 2)}") testParse("1 * 2", "{(:multiply 1 2)}")
testParse("1 / 2", "{(::divide 1 2)}") testParse("1 / 2", "{(:divide 1 2)}")
testParse("1 * 2 * 3", "{(::multiply (::multiply 1 2) 3)}") testParse("1 * 2 * 3", "{(:multiply (:multiply 1 2) 3)}")
testParse("1 * 2 / 3", "{(::divide (::multiply 1 2) 3)}") testParse("1 * 2 / 3", "{(:divide (:multiply 1 2) 3)}")
testParse("1 / 2 * 3", "{(::multiply (::divide 1 2) 3)}") testParse("1 / 2 * 3", "{(:multiply (:divide 1 2) 3)}")
testParse("1 / 2 / 3", "{(::divide (::divide 1 2) 3)}") testParse("1 / 2 / 3", "{(:divide (:divide 1 2) 3)}")
testParse("1 * 2 + 3 * 4", "{(::add (::multiply 1 2) (::multiply 3 4))}") testParse("1 * 2 + 3 * 4", "{(:add (:multiply 1 2) (:multiply 3 4))}")
testParse("1 * 2 - 3 * 4", "{(::subtract (::multiply 1 2) (::multiply 3 4))}") testParse("1 * 2 - 3 * 4", "{(:subtract (:multiply 1 2) (:multiply 3 4))}")
testParse("1 * 2 .+ 3 * 4", "{(::dotAdd (::multiply 1 2) (::multiply 3 4))}") testParse("1 * 2 .+ 3 * 4", "{(:dotAdd (:multiply 1 2) (:multiply 3 4))}")
testParse("1 * 2 .- 3 * 4", "{(::dotSubtract (::multiply 1 2) (::multiply 3 4))}") testParse("1 * 2 .- 3 * 4", "{(:dotSubtract (:multiply 1 2) (:multiply 3 4))}")
testParse("1 * 2 + 3 .* 4", "{(::add (::multiply 1 2) (::dotMultiply 3 4))}") testParse("1 * 2 + 3 .* 4", "{(:add (:multiply 1 2) (:dotMultiply 3 4))}")
testParse("1 * 2 + 3 / 4", "{(::add (::multiply 1 2) (::divide 3 4))}") testParse("1 * 2 + 3 / 4", "{(:add (:multiply 1 2) (:divide 3 4))}")
testParse("1 * 2 + 3 ./ 4", "{(::add (::multiply 1 2) (::dotDivide 3 4))}") testParse("1 * 2 + 3 ./ 4", "{(:add (:multiply 1 2) (:dotDivide 3 4))}")
testParse("1 * 2 - 3 .* 4", "{(::subtract (::multiply 1 2) (::dotMultiply 3 4))}") testParse("1 * 2 - 3 .* 4", "{(:subtract (:multiply 1 2) (:dotMultiply 3 4))}")
testParse("1 * 2 - 3 / 4", "{(::subtract (::multiply 1 2) (::divide 3 4))}") testParse("1 * 2 - 3 / 4", "{(:subtract (:multiply 1 2) (:divide 3 4))}")
testParse("1 * 2 - 3 ./ 4", "{(::subtract (::multiply 1 2) (::dotDivide 3 4))}") testParse("1 * 2 - 3 ./ 4", "{(:subtract (:multiply 1 2) (:dotDivide 3 4))}")
testParse("1 * 2 - 3 * 4^5", "{(::subtract (::multiply 1 2) (::multiply 3 (::pow 4 5)))}") testParse("1 * 2 - 3 * 4^5", "{(:subtract (:multiply 1 2) (:multiply 3 (:pow 4 5)))}")
testParse( testParse(
"1 * 2 - 3 * 4^5^6", "1 * 2 - 3 * 4^5^6",
"{(::subtract (::multiply 1 2) (::multiply 3 (::pow (::pow 4 5) 6)))}", "{(:subtract (:multiply 1 2) (:multiply 3 (:pow (:pow 4 5) 6)))}",
) )
testParse("1 * -a[-2]", "{(::multiply 1 (::unaryMinus (::$_atIndex_$ :a (::unaryMinus 2))))}") testParse("1 * -a[-2]", "{(:multiply 1 (:unaryMinus (:$_atIndex_$ :a (:unaryMinus 2))))}")
}) })
describe("multi-line", () => { describe("multi-line", () => {
@ -70,27 +69,27 @@ describe("Peggy parse", () => {
describe("functions", () => { describe("functions", () => {
testParse("identity(x) = x", "{:identity = {|:x| {:x}}}") // Function definitions become lambda assignments testParse("identity(x) = x", "{:identity = {|:x| {:x}}}") // Function definitions become lambda assignments
testParse("identity(x)", "{(::identity :x)}") testParse("identity(x)", "{(:identity :x)}")
}) })
describe("arrays", () => { describe("arrays", () => {
testParse("[]", "{(::$_constructArray_$ ())}") testParse("[]", "{[]}")
testParse("[0, 1, 2]", "{(::$_constructArray_$ (0 1 2))}") testParse("[0, 1, 2]", "{[0; 1; 2]}")
testParse("['hello', 'world']", "{(::$_constructArray_$ ('hello' 'world'))}") testParse("['hello', 'world']", "{['hello'; 'world']}")
testParse("([0,1,2])[1]", "{(::$_atIndex_$ (::$_constructArray_$ (0 1 2)) 1)}") testParse("([0,1,2])[1]", "{(:$_atIndex_$ [0; 1; 2] 1)}")
}) })
describe("records", () => { describe("records", () => {
testParse("{a: 1, b: 2}", "{(::$_constructRecord_$ ('a': 1 'b': 2))}") testParse("{a: 1, b: 2}", "{{'a': 1, 'b': 2}}")
testParse("{1+0: 1, 2+0: 2}", "{(::$_constructRecord_$ ((::add 1 0): 1 (::add 2 0): 2))}") // key can be any expression testParse("{1+0: 1, 2+0: 2}", "{{(:add 1 0): 1, (:add 2 0): 2}}") // key can be any expression
testParse("record.property", "{(::$_atIndex_$ :record 'property')}") testParse("record.property", "{(:$_atIndex_$ :record 'property')}")
}) })
describe("post operators", () => { describe("post operators", () => {
//function call, array and record access are post operators with higher priority than unary operators //function call, array and record access are post operators with higher priority than unary operators
testParse("a==!b(1)", "{(::equal :a (::not (::b 1)))}") testParse("a==!b(1)", "{(:equal :a (:not (:b 1)))}")
testParse("a==!b[1]", "{(::equal :a (::not (::$_atIndex_$ :b 1)))}") testParse("a==!b[1]", "{(:equal :a (:not (:$_atIndex_$ :b 1)))}")
testParse("a==!b.one", "{(::equal :a (::not (::$_atIndex_$ :b 'one')))}") testParse("a==!b.one", "{(:equal :a (:not (:$_atIndex_$ :b 'one')))}")
}) })
describe("comments", () => { describe("comments", () => {
@ -100,10 +99,10 @@ describe("Peggy parse", () => {
testParse("/* This is a multi line comment */ 1", "{1}") testParse("/* This is a multi line comment */ 1", "{1}")
testParse( testParse(
` `
/* This is /* This is
a multi line a multi line
comment */ comment */
1`, 1`,
"{1}", "{1}",
) )
}) })
@ -126,70 +125,67 @@ describe("Peggy parse", () => {
}) })
describe("logical", () => { describe("logical", () => {
testParse("true || false", "{(::or true false)}") testParse("true || false", "{(:or true false)}")
testParse("true && false", "{(::and true false)}") testParse("true && false", "{(:and true false)}")
testParse("a * b + c", "{(::add (::multiply :a :b) :c)}") // for comparison testParse("a * b + c", "{(:add (:multiply :a :b) :c)}") // for comparison
testParse("a && b || c", "{(::or (::and :a :b) :c)}") testParse("a && b || c", "{(:or (:and :a :b) :c)}")
testParse("a && b || c && d", "{(::or (::and :a :b) (::and :c :d))}") testParse("a && b || c && d", "{(:or (:and :a :b) (:and :c :d))}")
testParse("a && !b || c", "{(::or (::and :a (::not :b)) :c)}") testParse("a && !b || c", "{(:or (:and :a (:not :b)) :c)}")
testParse("a && b==c || d", "{(::or (::and :a (::equal :b :c)) :d)}") testParse("a && b==c || d", "{(:or (:and :a (:equal :b :c)) :d)}")
testParse("a && b!=c || d", "{(::or (::and :a (::unequal :b :c)) :d)}") testParse("a && b!=c || d", "{(:or (:and :a (:unequal :b :c)) :d)}")
testParse("a && !(b==c) || d", "{(::or (::and :a (::not (::equal :b :c))) :d)}") testParse("a && !(b==c) || d", "{(:or (:and :a (:not (:equal :b :c))) :d)}")
testParse("a && b>=c || d", "{(::or (::and :a (::largerEq :b :c)) :d)}") testParse("a && b>=c || d", "{(:or (:and :a (:largerEq :b :c)) :d)}")
testParse("a && !(b>=c) || d", "{(::or (::and :a (::not (::largerEq :b :c))) :d)}") testParse("a && !(b>=c) || d", "{(:or (:and :a (:not (:largerEq :b :c))) :d)}")
testParse("a && b<=c || d", "{(::or (::and :a (::smallerEq :b :c)) :d)}") testParse("a && b<=c || d", "{(:or (:and :a (:smallerEq :b :c)) :d)}")
testParse("a && b>c || d", "{(::or (::and :a (::larger :b :c)) :d)}") testParse("a && b>c || d", "{(:or (:and :a (:larger :b :c)) :d)}")
testParse("a && b<c || d", "{(::or (::and :a (::smaller :b :c)) :d)}") testParse("a && b<c || d", "{(:or (:and :a (:smaller :b :c)) :d)}")
testParse("a && b<c[i] || d", "{(::or (::and :a (::smaller :b (::$_atIndex_$ :c :i))) :d)}") testParse("a && b<c[i] || d", "{(:or (:and :a (:smaller :b (:$_atIndex_$ :c :i))) :d)}")
testParse("a && b<c.i || d", "{(::or (::and :a (::smaller :b (::$_atIndex_$ :c 'i'))) :d)}") testParse("a && b<c.i || d", "{(:or (:and :a (:smaller :b (:$_atIndex_$ :c 'i'))) :d)}")
testParse("a && b<c(i) || d", "{(::or (::and :a (::smaller :b (::c :i))) :d)}") testParse("a && b<c(i) || d", "{(:or (:and :a (:smaller :b (:c :i))) :d)}")
testParse("a && b<1+2 || d", "{(::or (::and :a (::smaller :b (::add 1 2))) :d)}") testParse("a && b<1+2 || d", "{(:or (:and :a (:smaller :b (:add 1 2))) :d)}")
testParse( testParse("a && b<1+2*3 || d", "{(:or (:and :a (:smaller :b (:add 1 (:multiply 2 3)))) :d)}")
"a && b<1+2*3 || d",
"{(::or (::and :a (::smaller :b (::add 1 (::multiply 2 3)))) :d)}",
)
testParse( testParse(
"a && b<1+2*-3+4 || d", "a && b<1+2*-3+4 || d",
"{(::or (::and :a (::smaller :b (::add (::add 1 (::multiply 2 (::unaryMinus 3))) 4))) :d)}", "{(:or (:and :a (:smaller :b (:add (:add 1 (:multiply 2 (:unaryMinus 3))) 4))) :d)}",
) )
testParse( testParse(
"a && b<1+2*3 || d ? true : false", "a && b<1+2*3 || d ? true : false",
"{(::$$_ternary_$$ (::or (::and :a (::smaller :b (::add 1 (::multiply 2 3)))) :d) true false)}", "{(::$$_ternary_$$ (:or (:and :a (:smaller :b (:add 1 (:multiply 2 3)))) :d) true false)}",
) )
}) })
describe("pipe", () => { describe("pipe", () => {
testParse("1 -> add(2)", "{(::add 1 2)}") testParse("1 -> add(2)", "{(:add 1 2)}")
testParse("-1 -> add(2)", "{(::add (::unaryMinus 1) 2)}") testParse("-1 -> add(2)", "{(:add (:unaryMinus 1) 2)}")
testParse("-a[1] -> add(2)", "{(::add (::unaryMinus (::$_atIndex_$ :a 1)) 2)}") testParse("-a[1] -> add(2)", "{(:add (:unaryMinus (:$_atIndex_$ :a 1)) 2)}")
testParse("-f(1) -> add(2)", "{(::add (::unaryMinus (::f 1)) 2)}") testParse("-f(1) -> add(2)", "{(:add (:unaryMinus (:f 1)) 2)}")
testParse("1 + 2 -> add(3)", "{(::add 1 (::add 2 3))}") testParse("1 + 2 -> add(3)", "{(:add 1 (:add 2 3))}")
testParse("1 -> add(2) * 3", "{(::multiply (::add 1 2) 3)}") testParse("1 -> add(2) * 3", "{(:multiply (:add 1 2) 3)}")
testParse("1 -> subtract(2)", "{(::subtract 1 2)}") testParse("1 -> subtract(2)", "{(:subtract 1 2)}")
testParse("-1 -> subtract(2)", "{(::subtract (::unaryMinus 1) 2)}") testParse("-1 -> subtract(2)", "{(:subtract (:unaryMinus 1) 2)}")
testParse("1 -> subtract(2) * 3", "{(::multiply (::subtract 1 2) 3)}") testParse("1 -> subtract(2) * 3", "{(:multiply (:subtract 1 2) 3)}")
}) })
describe("elixir pipe", () => { describe("elixir pipe", () => {
//handled together with -> so there is no need for seperate tests //handled together with -> so there is no need for seperate tests
testParse("1 |> add(2)", "{(::add 1 2)}") testParse("1 |> add(2)", "{(:add 1 2)}")
}) })
describe("to", () => { describe("to", () => {
testParse("1 to 2", "{(::credibleIntervalToDistribution 1 2)}") testParse("1 to 2", "{(:credibleIntervalToDistribution 1 2)}")
testParse("-1 to -2", "{(::credibleIntervalToDistribution (::unaryMinus 1) (::unaryMinus 2))}") // lower than unary testParse("-1 to -2", "{(:credibleIntervalToDistribution (:unaryMinus 1) (:unaryMinus 2))}") // lower than unary
testParse( testParse(
"a[1] to a[2]", "a[1] to a[2]",
"{(::credibleIntervalToDistribution (::$_atIndex_$ :a 1) (::$_atIndex_$ :a 2))}", "{(:credibleIntervalToDistribution (:$_atIndex_$ :a 1) (:$_atIndex_$ :a 2))}",
) // lower than post ) // lower than post
testParse( testParse(
"a.p1 to a.p2", "a.p1 to a.p2",
"{(::credibleIntervalToDistribution (::$_atIndex_$ :a 'p1') (::$_atIndex_$ :a 'p2'))}", "{(:credibleIntervalToDistribution (:$_atIndex_$ :a 'p1') (:$_atIndex_$ :a 'p2'))}",
) // lower than post ) // lower than post
testParse("1 to 2 + 3", "{(::add (::credibleIntervalToDistribution 1 2) 3)}") // higher than binary operators testParse("1 to 2 + 3", "{(:credibleIntervalToDistribution 1 (:add 2 3))}")
testParse( testParse(
"1->add(2) to 3->add(4) -> add(4)", "1->add(2) to 3->add(4) -> add(4)",
"{(::credibleIntervalToDistribution (::add 1 2) (::add (::add 3 4) 4))}", "{(:credibleIntervalToDistribution (:add 1 2) (:add (:add 3 4) 4))}",
) // lower than chain ) // lower than chain
}) })
@ -200,8 +196,8 @@ describe("Peggy parse", () => {
}) })
describe("lambda", () => { describe("lambda", () => {
testParse("{|x| x}", "{{|:x| {:x}}}") testParse("{|x| x}", "{{|:x| :x}}")
testParse("f={|x| x}", "{:f = {{|:x| {:x}}}}") testParse("f={|x| x}", "{:f = {|:x| :x}}")
testParse("f(x)=x", "{:f = {|:x| {:x}}}") // Function definitions are lambda assignments testParse("f(x)=x", "{:f = {|:x| {:x}}}") // Function definitions are lambda assignments
testParse("f(x)=x ? 1 : 0", "{:f = {|:x| {(::$$_ternary_$$ :x 1 0)}}}") // Function definitions are lambda assignments testParse("f(x)=x ? 1 : 0", "{:f = {|:x| {(::$$_ternary_$$ :x 1 0)}}}") // Function definitions are lambda assignments
}) })
@ -209,31 +205,25 @@ describe("Peggy parse", () => {
describe("Using lambda as value", () => { describe("Using lambda as value", () => {
testParse( testParse(
"myadd(x,y)=x+y; z=myadd; z", "myadd(x,y)=x+y; z=myadd; z",
"{:myadd = {|:x,:y| {(::add :x :y)}}; :z = {:myadd}; :z}", "{:myadd = {|:x,:y| {(:add :x :y)}}; :z = {:myadd}; :z}",
) )
testParse( testParse(
"myadd(x,y)=x+y; z=[myadd]; z", "myadd(x,y)=x+y; z=[myadd]; z",
"{:myadd = {|:x,:y| {(::add :x :y)}}; :z = {(::$_constructArray_$ (:myadd))}; :z}", "{:myadd = {|:x,:y| {(:add :x :y)}}; :z = {[:myadd]}; :z}",
) )
testParse( testParse(
"myaddd(x,y)=x+y; z={x: myaddd}; z", "myaddd(x,y)=x+y; z={x: myaddd}; z",
"{:myaddd = {|:x,:y| {(::add :x :y)}}; :z = {(::$_constructRecord_$ ('x': :myaddd))}; :z}", "{:myaddd = {|:x,:y| {(:add :x :y)}}; :z = {{'x': :myaddd}}; :z}",
)
testParse("f({|x| x+1})", "{(::f {|:x| {(::add :x 1)}})}")
testParse("map(arr, {|x| x+1})", "{(::map :arr {|:x| {(::add :x 1)}})}")
testParse(
"map([1,2,3], {|x| x+1})",
"{(::map (::$_constructArray_$ (1 2 3)) {|:x| {(::add :x 1)}})}",
)
testParse(
"[1,2,3]->map({|x| x+1})",
"{(::map (::$_constructArray_$ (1 2 3)) {|:x| {(::add :x 1)}})}",
) )
testParse("f({|x| x+1})", "{(:f {|:x| (:add :x 1)})}")
testParse("map(arr, {|x| x+1})", "{(:map :arr {|:x| (:add :x 1)})}")
testParse("map([1,2,3], {|x| x+1})", "{(:map [1; 2; 3] {|:x| (:add :x 1)})}")
testParse("[1,2,3]->map({|x| x+1})", "{(:map [1; 2; 3] {|:x| (:add :x 1)})}")
}) })
describe("unit", () => { describe("unit", () => {
testParse("1m", "{(::fromUnit_m 1)}") testParse("1m", "{(:fromUnit_m 1)}")
testParse("1M", "{(::fromUnit_M 1)}") testParse("1M", "{(:fromUnit_M 1)}")
testParse("1m+2cm", "{(::add (::fromUnit_m 1) (::fromUnit_cm 2))}") testParse("1m+2cm", "{(:add (:fromUnit_m 1) (:fromUnit_cm 2))}")
}) })
describe("Module", () => { describe("Module", () => {
testParse("x", "{:x}") testParse("x", "{:x}")
@ -244,118 +234,118 @@ describe("Peggy parse", () => {
describe("parsing new line", () => { describe("parsing new line", () => {
testParse( testParse(
` `
a + a +
b`, b`,
"{(::add :a :b)}", "{(:add :a :b)}",
) )
testParse( testParse(
` `
x= x=
1`, 1`,
"{:x = {1}}", "{:x = {1}}",
) )
testParse( testParse(
` `
x=1 x=1
y=2`, y=2`,
"{:x = {1}; :y = {2}}", "{:x = {1}; :y = {2}}",
) )
testParse( testParse(
` `
x={ x={
y=2; y=2;
y } y }
x`, x`,
"{:x = {:y = {2}; :y}; :x}", "{:x = {:y = {2}; :y}; :x}",
) )
testParse( testParse(
` `
x={ x={
y=2
y }
x`,
"{:x = {:y = {2}; :y}; :x}",
)
testParse(
`
x={
y=2
y
}
x`,
"{:x = {:y = {2}; :y}; :x}",
)
testParse(
`
x=1
y=2 y=2
z=3 y }
`, x`,
"{:x = {:y = {2}; :y}; :x}",
)
testParse(
`
x={
y=2
y
}
x`,
"{:x = {:y = {2}; :y}; :x}",
)
testParse(
`
x=1
y=2
z=3
`,
"{:x = {1}; :y = {2}; :z = {3}}", "{:x = {1}; :y = {2}; :z = {3}}",
) )
testParse( testParse(
` `
f={ f={
x=1 x=1
y=2 y=2
z=3 z=3
x+y+z x+y+z
}
`,
"{:f = {:x = {1}; :y = {2}; :z = {3}; (:add (:add :x :y) :z)}}",
)
testParse(
`
f={
x=1
y=2
z=3
x+y+z
}
g=f+4
g
`,
"{:f = {:x = {1}; :y = {2}; :z = {3}; (:add (:add :x :y) :z)}; :g = {(:add :f 4)}; :g}",
)
testParse(
`
f =
{
x=1; //x
y=2 //y
z=
3
x+
y+
z
} }
`, g =
"{:f = {:x = {1}; :y = {2}; :z = {3}; (::add (::add :x :y) :z)}}", f +
4
g ->
h ->
p ->
q
`,
"{:f = {:x = {1}; :y = {2}; :z = {3}; (:add (:add :x :y) :z)}; :g = {(:add :f 4)}; (:q (:p (:h :g)))}",
) )
testParse( testParse(
` `
f={ a |>
x=1 b |>
y=2 c |>
z=3 d
x+y+z `,
} "{(:d (:c (:b :a)))}",
g=f+4
g
`,
"{:f = {:x = {1}; :y = {2}; :z = {3}; (::add (::add :x :y) :z)}; :g = {(::add :f 4)}; :g}",
) )
testParse( testParse(
` `
f = a |>
{ b |>
x=1; //x c |>
y=2 //y d +
z= e
3 `,
x+ "{(:add (:d (:c (:b :a))) :e)}",
y+
z
}
g =
f +
4
g ->
h ->
p ->
q
`,
"{:f = {:x = {1}; :y = {2}; :z = {3}; (::add (::add :x :y) :z)}; :g = {(::add :f 4)}; (::q (::p (::h :g)))}",
)
testParse(
`
a |>
b |>
c |>
d
`,
"{(::d (::c (::b :a)))}",
)
testParse(
`
a |>
b |>
c |>
d +
e
`,
"{(::add (::d (::c (::b :a))) :e)}",
) )
}) })

View File

@ -3,77 +3,83 @@ open Reducer_Peggy_TestHelpers
describe("Peggy parse type", () => { describe("Peggy parse type", () => {
describe("type of", () => { describe("type of", () => {
testParse("p: number", "{(::$_typeOf_$ :p #number)}") testParse("p: number", "{(::$_typeOf_$ :p #number); (::$_endOfOuterBlock_$ () ())}")
}) })
describe("type alias", () => { describe("type alias", () => {
testParse("type index=number", "{(::$_typeAlias_$ #index #number)}") testParse(
"type index=number",
"{(::$_typeAlias_$ #index #number); (::$_endOfOuterBlock_$ () ())}",
)
}) })
describe("type or", () => { describe("type or", () => {
testParse( testParse(
"answer: number|string", "answer: number|string",
"{(::$_typeOf_$ :answer (::$_typeOr_$ (::$_constructArray_$ (#number #string))))}", "{(::$_typeOf_$ :answer (::$_typeOr_$ (::$_constructArray_$ #number #string))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("type function", () => { describe("type function", () => {
testParse( testParse(
"f: number=>number=>number", "f: number=>number=>number",
"{(::$_typeOf_$ :f (::$_typeFunction_$ (::$_constructArray_$ (#number #number #number))))}", "{(::$_typeOf_$ :f (::$_typeFunction_$ (::$_constructArray_$ #number #number #number))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("high priority contract", () => { describe("high priority contract", () => {
testParse( testParse(
"answer: number<-min<-max(100)|string", "answer: number<-min<-max(100)|string",
"{(::$_typeOf_$ :answer (::$_typeOr_$ (::$_constructArray_$ ((::$_typeModifier_max_$ (::$_typeModifier_min_$ #number) 100) #string))))}", "{(::$_typeOf_$ :answer (::$_typeOr_$ (::$_constructArray_$ (::$_typeModifier_max_$ (::$_typeModifier_min_$ #number) 100) #string))); (::$_endOfOuterBlock_$ () ())}",
) )
testParse( testParse(
"answer: number<-memberOf([1,3,5])", "answer: number<-memberOf([1,3,5])",
"{(::$_typeOf_$ :answer (::$_typeModifier_memberOf_$ #number (::$_constructArray_$ (1 3 5))))}", "{(::$_typeOf_$ :answer (::$_typeModifier_memberOf_$ #number (::$_constructArray_$ 1 3 5))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("low priority contract", () => { describe("low priority contract", () => {
testParse( testParse(
"answer: number | string $ opaque", "answer: number | string $ opaque",
"{(::$_typeOf_$ :answer (::$_typeModifier_opaque_$ (::$_typeOr_$ (::$_constructArray_$ (#number #string)))))}", "{(::$_typeOf_$ :answer (::$_typeModifier_opaque_$ (::$_typeOr_$ (::$_constructArray_$ #number #string)))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("type array", () => { describe("type array", () => {
testParse("answer: [number]", "{(::$_typeOf_$ :answer (::$_typeArray_$ #number))}") testParse(
"answer: [number]",
"{(::$_typeOf_$ :answer (::$_typeArray_$ #number)); (::$_endOfOuterBlock_$ () ())}",
)
}) })
describe("type record", () => { describe("type record", () => {
testParse( testParse(
"answer: {a: number, b: string}", "answer: {a: number, b: string}",
"{(::$_typeOf_$ :answer (::$_typeRecord_$ (::$_constructRecord_$ ('a': #number 'b': #string))))}", "{(::$_typeOf_$ :answer (::$_typeRecord_$ (::$_constructRecord_$ ('a': #number 'b': #string)))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("type constructor", () => { describe("type constructor", () => {
testParse( testParse(
"answer: Age(number)", "answer: Age(number)",
"{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Age (::$_constructArray_$ (#number))))}", "{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Age (::$_constructArray_$ #number))); (::$_endOfOuterBlock_$ () ())}",
) )
testParse( testParse(
"answer: Complex(number, number)", "answer: Complex(number, number)",
"{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Complex (::$_constructArray_$ (#number #number))))}", "{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Complex (::$_constructArray_$ #number #number))); (::$_endOfOuterBlock_$ () ())}",
) )
testParse( testParse(
"answer: Person({age: number, name: string})", "answer: Person({age: number, name: string})",
"{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Person (::$_constructArray_$ ((::$_typeRecord_$ (::$_constructRecord_$ ('age': #number 'name': #string)))))))}", "{(::$_typeOf_$ :answer (::$_typeConstructor_$ #Person (::$_constructArray_$ (::$_typeRecord_$ (::$_constructRecord_$ ('age': #number 'name': #string)))))); (::$_endOfOuterBlock_$ () ())}",
) )
testParse( testParse(
"weekend: Saturday | Sunday", "weekend: Saturday | Sunday",
"{(::$_typeOf_$ :weekend (::$_typeOr_$ (::$_constructArray_$ ((::$_typeConstructor_$ #Saturday (::$_constructArray_$ ())) (::$_typeConstructor_$ #Sunday (::$_constructArray_$ ()))))))}", "{(::$_typeOf_$ :weekend (::$_typeOr_$ (::$_constructArray_$ (::$_typeConstructor_$ #Saturday (::$_constructArray_$)) (::$_typeConstructor_$ #Sunday (::$_constructArray_$))))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("type parenthesis", () => { describe("type parenthesis", () => {
//$ is introduced to avoid parenthesis //$ is introduced to avoid parenthesis
testParse( testParse(
"answer: (number|string)<-opaque", "answer: (number|string)<-opaque",
"{(::$_typeOf_$ :answer (::$_typeModifier_opaque_$ (::$_typeOr_$ (::$_constructArray_$ (#number #string)))))}", "{(::$_typeOf_$ :answer (::$_typeModifier_opaque_$ (::$_typeOr_$ (::$_constructArray_$ #number #string)))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
describe("squiggle expressions in type contracts", () => { describe("squiggle expressions in type contracts", () => {
testParse( testParse(
"odds1 = [1,3,5]; odds2 = [7, 9]; type odds = number<-memberOf(concat(odds1, odds2))", "odds1 = [1,3,5]; odds2 = [7, 9]; type odds = number<-memberOf(concat(odds1, odds2))",
"{:odds1 = {(::$_constructArray_$ (1 3 5))}; :odds2 = {(::$_constructArray_$ (7 9))}; (::$_typeAlias_$ #odds (::$_typeModifier_memberOf_$ #number (::concat :odds1 :odds2)))}", "{:odds1 = {(::$_constructArray_$ 1 3 5)}; :odds2 = {(::$_constructArray_$ 7 9)}; (::$_typeAlias_$ #odds (::$_typeModifier_memberOf_$ #number (::concat :odds1 :odds2))); (::$_endOfOuterBlock_$ () ())}",
) )
}) })
}) })

View File

@ -1,6 +1,5 @@
module Expression = Reducer_Expression module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ExpressionValue = ReducerInterface.InternalExpressionValue
module Parse = Reducer_Peggy_Parse module Parse = Reducer_Peggy_Parse
module Result = Belt.Result module Result = Belt.Result
module ToExpression = Reducer_Peggy_ToExpression module ToExpression = Reducer_Peggy_ToExpression
@ -10,12 +9,12 @@ open Jest
open Expect open Expect
let expectParseToBe = (expr, answer) => let expectParseToBe = (expr, answer) =>
Parse.parse(expr)->Parse.toStringResult->expect->toBe(answer) Parse.parse(expr, "test")->Parse.toStringResult->expect->toBe(answer)
let testParse = (expr, answer) => test(expr, () => expectParseToBe(expr, answer)) let testParse = (expr, answer) => test(expr, () => expectParseToBe(expr, answer))
let expectToExpressionToBe = (expr, answer, ~v="_", ()) => { let expectExpressionToBe = (expr, answer, ~v="_", ()) => {
let rExpr = Parse.parse(expr)->Result.map(ToExpression.fromNode) let rExpr = Parse.parse(expr, "test")->Result.map(ToExpression.fromNode)
let a1 = rExpr->ExpressionT.toStringResultOkless let a1 = rExpr->ExpressionT.toStringResultOkless
if v == "_" { if v == "_" {
@ -23,30 +22,24 @@ let expectToExpressionToBe = (expr, answer, ~v="_", ()) => {
} else { } else {
let a2 = let a2 =
rExpr rExpr
->Result.flatMap(expr => ->E.R2.errMap(e => e->SqError.fromParseError)
Expression.reduceExpression( ->Result.flatMap(expr => Expression.BackCompatible.evaluate(expr))
expr, ->Reducer_Value.toStringResultOkless
ReducerInterface_StdLib.internalStdLib,
ExpressionValue.defaultEnvironment,
)
)
->Reducer_Helpers.rRemoveDefaultsInternal
->ExpressionValue.toStringResultOkless
(a1, a2)->expect->toEqual((answer, v)) (a1, a2)->expect->toEqual((answer, v))
} }
} }
let testToExpression = (expr, answer, ~v="_", ()) => let testToExpression = (expr, answer, ~v="_", ()) =>
test(expr, () => expectToExpressionToBe(expr, answer, ~v, ())) test(expr, () => expectExpressionToBe(expr, answer, ~v, ()))
module MyOnly = { module MyOnly = {
let testParse = (expr, answer) => Only.test(expr, () => expectParseToBe(expr, answer)) let testParse = (expr, answer) => Only.test(expr, () => expectParseToBe(expr, answer))
let testToExpression = (expr, answer, ~v="_", ()) => let testToExpression = (expr, answer, ~v="_", ()) =>
Only.test(expr, () => expectToExpressionToBe(expr, answer, ~v, ())) Only.test(expr, () => expectExpressionToBe(expr, answer, ~v, ()))
} }
module MySkip = { module MySkip = {
let testParse = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer)) let testParse = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer))
let testToExpression = (expr, answer, ~v="_", ()) => let testToExpression = (expr, answer, ~v="_", ()) =>
Skip.test(expr, () => expectToExpressionToBe(expr, answer, ~v, ())) Skip.test(expr, () => expectExpressionToBe(expr, answer, ~v, ()))
} }

View File

@ -0,0 +1,12 @@
open Jest
open Reducer_Peggy_TestHelpers
// Note: these tests aren't useful anymore since outer block macro got deleted.
// Probably can be removed or folded into other Peggy tests.
describe("Peggy Outer Block", () => {
testToExpression("1", "1", ~v="1", ())
testToExpression("x=1", "x = {1}", ~v="()", ())
testToExpression("x=1; y=2", "x = {1}; y = {2}", ~v="()", ())
testToExpression("x=1; 2", "x = {1}; 2", ~v="2", ())
testToExpression("x={a=1; a}; x", "x = {a = {1}; a}; x", ~v="1", ())
})

View File

@ -1,5 +1,4 @@
module Bindings = Reducer_Bindings module Bindings = Reducer_Bindings
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
open Jest open Jest
open Reducer_Peggy_TestHelpers open Reducer_Peggy_TestHelpers
@ -7,147 +6,121 @@ open Reducer_Peggy_TestHelpers
describe("Peggy to Expression", () => { describe("Peggy to Expression", () => {
describe("literals operators parenthesis", () => { describe("literals operators parenthesis", () => {
// Note that there is always an outer block. Otherwise, external bindings are ignored at the first statement // Note that there is always an outer block. Otherwise, external bindings are ignored at the first statement
testToExpression("1", "{1}", ~v="1", ()) testToExpression("1", "1", ~v="1", ())
testToExpression("'hello'", "{'hello'}", ~v="'hello'", ()) testToExpression("'hello'", "'hello'", ~v="'hello'", ())
testToExpression("true", "{true}", ~v="true", ()) testToExpression("true", "true", ~v="true", ())
testToExpression("1+2", "{(:add 1 2)}", ~v="3", ()) testToExpression("1+2", "(add)(1, 2)", ~v="3", ())
testToExpression("add(1,2)", "{(:add 1 2)}", ~v="3", ()) testToExpression("add(1,2)", "(add)(1, 2)", ~v="3", ())
testToExpression("(1)", "{1}", ()) testToExpression("(1)", "1", ())
testToExpression("(1+2)", "{(:add 1 2)}", ()) testToExpression("(1+2)", "(add)(1, 2)", ())
}) })
describe("unary", () => { describe("unary", () => {
testToExpression("-1", "{(:unaryMinus 1)}", ~v="-1", ()) testToExpression("-1", "(unaryMinus)(1)", ~v="-1", ())
testToExpression("!true", "{(:not true)}", ~v="false", ()) testToExpression("!true", "(not)(true)", ~v="false", ())
testToExpression("1 + -1", "{(:add 1 (:unaryMinus 1))}", ~v="0", ()) testToExpression("1 + -1", "(add)(1, (unaryMinus)(1))", ~v="0", ())
testToExpression("-a[0]", "{(:unaryMinus (:$_atIndex_$ :a 0))}", ()) testToExpression("-a[0]", "(unaryMinus)(($_atIndex_$)(a, 0))", ())
}) })
describe("multi-line", () => { describe("multi-line", () => {
testToExpression("x=1; 2", "{(:$_let_$ :x {1}); 2}", ~v="2", ()) testToExpression("x=1; 2", "x = {1}; 2", ~v="2", ())
testToExpression("x=1; y=2", "{(:$_let_$ :x {1}); (:$_let_$ :y {2})}", ~v="@{x: 1,y: 2}", ()) testToExpression("x=1; y=2", "x = {1}; y = {2}", ())
}) })
describe("variables", () => { describe("variables", () => {
testToExpression("x = 1", "{(:$_let_$ :x {1})}", ~v="@{x: 1}", ()) testToExpression("x = 1", "x = {1}", ())
testToExpression("x", "{:x}", ~v=":x", ()) //TODO: value should return error testToExpression("x", "x", ~v="Error(x is not defined)", ()) //TODO: value should return error
testToExpression("x = 1; x", "{(:$_let_$ :x {1}); :x}", ~v="1", ()) testToExpression("x = 1; x", "x = {1}; x", ~v="1", ())
}) })
describe("functions", () => { describe("functions", () => {
testToExpression( testToExpression("identity(x) = x", "identity = {|x| {x}}", ()) // Function definitions become lambda assignments
"identity(x) = x", testToExpression("identity(x)", "(identity)(x)", ()) // Note value returns error properly
"{(:$_let_$ :identity (:$$_lambda_$$ [x] {:x}))}",
~v="@{identity: lambda(x=>internal code)}",
(),
) // Function definitions become lambda assignments
testToExpression("identity(x)", "{(:identity :x)}", ()) // Note value returns error properly
testToExpression( testToExpression(
"f(x) = x> 2 ? 0 : 1; f(3)", "f(x) = x> 2 ? 0 : 1; f(3)",
"{(:$_let_$ :f (:$$_lambda_$$ [x] {(:$$_ternary_$$ (:larger :x 2) 0 1)})); (:f 3)}", "f = {|x| {(larger)(x, 2) ? (0) : (1)}}; (f)(3)",
~v="0", ~v="0",
(), (),
) )
}) })
describe("arrays", () => { describe("arrays", () => {
testToExpression("[]", "{(:$_constructArray_$ ())}", ~v="[]", ()) testToExpression("[]", "[]", ~v="[]", ())
testToExpression("[0, 1, 2]", "{(:$_constructArray_$ (0 1 2))}", ~v="[0,1,2]", ()) testToExpression("[0, 1, 2]", "[0, 1, 2]", ~v="[0,1,2]", ())
testToExpression( testToExpression("['hello', 'world']", "['hello', 'world']", ~v="['hello','world']", ())
"['hello', 'world']", testToExpression("([0,1,2])[1]", "($_atIndex_$)([0, 1, 2], 1)", ~v="1", ())
"{(:$_constructArray_$ ('hello' 'world'))}",
~v="['hello','world']",
(),
)
testToExpression("([0,1,2])[1]", "{(:$_atIndex_$ (:$_constructArray_$ (0 1 2)) 1)}", ~v="1", ())
}) })
describe("records", () => { describe("records", () => {
testToExpression( testToExpression("{a: 1, b: 2}", "{'a': 1, 'b': 2}", ~v="{a: 1,b: 2}", ())
"{a: 1, b: 2}", testToExpression("{1+0: 1, 2+0: 2}", "{(add)(1, 0): 1, (add)(2, 0): 2}", ()) // key can be any expression
"{(:$_constructRecord_$ (('a' 1) ('b' 2)))}", testToExpression("record.property", "($_atIndex_$)(record, 'property')", ())
~v="{a: 1,b: 2}",
(),
)
testToExpression(
"{1+0: 1, 2+0: 2}",
"{(:$_constructRecord_$ (((:add 1 0) 1) ((:add 2 0) 2)))}",
(),
) // key can be any expression
testToExpression("record.property", "{(:$_atIndex_$ :record 'property')}", ())
testToExpression( testToExpression(
"record={property: 1}; record.property", "record={property: 1}; record.property",
"{(:$_let_$ :record {(:$_constructRecord_$ (('property' 1)))}); (:$_atIndex_$ :record 'property')}", "record = {{'property': 1}}; ($_atIndex_$)(record, 'property')",
~v="1", ~v="1",
(), (),
) )
}) })
describe("comments", () => { describe("comments", () => {
testToExpression("1 # This is a line comment", "{1}", ~v="1", ()) testToExpression("1 # This is a line comment", "1", ~v="1", ())
testToExpression("1 // This is a line comment", "{1}", ~v="1", ()) testToExpression("1 // This is a line comment", "1", ~v="1", ())
testToExpression("1 /* This is a multi line comment */", "{1}", ~v="1", ()) testToExpression("1 /* This is a multi line comment */", "1", ~v="1", ())
testToExpression("/* This is a multi line comment */ 1", "{1}", ~v="1", ()) testToExpression("/* This is a multi line comment */ 1", "1", ~v="1", ())
}) })
describe("ternary operator", () => { describe("ternary operator", () => {
testToExpression("true ? 1 : 0", "{(:$$_ternary_$$ true 1 0)}", ~v="1", ()) testToExpression("true ? 1 : 0", "true ? (1) : (0)", ~v="1", ())
testToExpression("false ? 1 : 0", "{(:$$_ternary_$$ false 1 0)}", ~v="0", ()) testToExpression("false ? 1 : 0", "false ? (1) : (0)", ~v="0", ())
testToExpression( testToExpression("true ? 1 : false ? 2 : 0", "true ? (1) : (false ? (2) : (0))", ~v="1", ()) // nested ternary
"true ? 1 : false ? 2 : 0", testToExpression("false ? 1 : false ? 2 : 0", "false ? (1) : (false ? (2) : (0))", ~v="0", ()) // nested ternary
"{(:$$_ternary_$$ true 1 (:$$_ternary_$$ false 2 0))}", describe(
~v="1", "ternary bindings",
(), () => {
) // nested ternary testToExpression(
testToExpression( // expression binding
"false ? 1 : false ? 2 : 0", "f(a) = a > 5 ? 1 : 0; f(6)",
"{(:$$_ternary_$$ false 1 (:$$_ternary_$$ false 2 0))}", "f = {|a| {(larger)(a, 5) ? (1) : (0)}}; (f)(6)",
~v="0", ~v="1",
(), (),
) // nested ternary )
describe("ternary bindings", () => { testToExpression(
testToExpression( // when true binding
// expression binding "f(a) = a > 5 ? a : 0; f(6)",
"f(a) = a > 5 ? 1 : 0; f(6)", "f = {|a| {(larger)(a, 5) ? (a) : (0)}}; (f)(6)",
"{(:$_let_$ :f (:$$_lambda_$$ [a] {(:$$_ternary_$$ (:larger :a 5) 1 0)})); (:f 6)}", ~v="6",
~v="1", (),
(), )
) testToExpression(
testToExpression( // when false binding
// when true binding "f(a) = a < 5 ? 1 : a; f(6)",
"f(a) = a > 5 ? a : 0; f(6)", "f = {|a| {(smaller)(a, 5) ? (1) : (a)}}; (f)(6)",
"{(:$_let_$ :f (:$$_lambda_$$ [a] {(:$$_ternary_$$ (:larger :a 5) :a 0)})); (:f 6)}", ~v="6",
~v="6", (),
(), )
) },
testToExpression( )
// when false binding
"f(a) = a < 5 ? 1 : a; f(6)",
"{(:$_let_$ :f (:$$_lambda_$$ [a] {(:$$_ternary_$$ (:smaller :a 5) 1 :a)})); (:f 6)}",
~v="6",
(),
)
})
}) })
describe("if then else", () => { describe("if then else", () => {
testToExpression("if true then 2 else 3", "{(:$$_ternary_$$ true {2} {3})}", ()) testToExpression("if true then 2 else 3", "true ? ({2}) : ({3})", ())
testToExpression("if true then {2} else {3}", "{(:$$_ternary_$$ true {2} {3})}", ()) testToExpression("if true then {2} else {3}", "true ? ({2}) : ({3})", ())
testToExpression( testToExpression(
"if false then {2} else if false then {4} else {5}", "if false then {2} else if false then {4} else {5}",
"{(:$$_ternary_$$ false {2} (:$$_ternary_$$ false {4} {5}))}", "false ? ({2}) : (false ? ({4}) : ({5}))",
(), (),
) //nested if ) //nested if
}) })
describe("pipe", () => { describe("pipe", () => {
testToExpression("1 -> add(2)", "{(:add 1 2)}", ~v="3", ()) testToExpression("1 -> add(2)", "(add)(1, 2)", ~v="3", ())
testToExpression("-1 -> add(2)", "{(:add (:unaryMinus 1) 2)}", ~v="1", ()) // note that unary has higher priority naturally testToExpression("-1 -> add(2)", "(add)((unaryMinus)(1), 2)", ~v="1", ()) // note that unary has higher priority naturally
testToExpression("1 -> add(2) * 3", "{(:multiply (:add 1 2) 3)}", ~v="9", ()) testToExpression("1 -> add(2) * 3", "(multiply)((add)(1, 2), 3)", ~v="9", ())
}) })
describe("elixir pipe", () => { describe("elixir pipe", () => {
testToExpression("1 |> add(2)", "{(:add 1 2)}", ~v="3", ()) testToExpression("1 |> add(2)", "(add)(1, 2)", ~v="3", ())
}) })
// see testParse for priorities of to and credibleIntervalToDistribution // see testParse for priorities of to and credibleIntervalToDistribution
@ -157,43 +130,28 @@ describe("Peggy to Expression", () => {
// Like lambdas they have a local scope. // Like lambdas they have a local scope.
testToExpression( testToExpression(
"y=99; x={y=1; y}", "y=99; x={y=1; y}",
"{(:$_let_$ :y {99}); (:$_let_$ :x {(:$_let_$ :y {1}); :y})}", "y = {99}; x = {y = {1}; y}",
~v="@{x: 1,y: 99}", // "{(:$_let_$ :y {99}); (:$_let_$ :x {(:$_let_$ :y {1}); :y}); (:$_endOfOuterBlock_$ () ())}",
(), (),
) )
}) })
describe("lambda", () => { describe("lambda", () => {
testToExpression("{|x| x}", "{(:$$_lambda_$$ [x] {:x})}", ~v="lambda(x=>internal code)", ()) testToExpression("{|x| x}", "{|x| x}", ~v="lambda(x=>internal code)", ())
testToExpression( testToExpression("f={|x| x}", "f = {|x| x}", ())
"f={|x| x}", testToExpression("f(x)=x", "f = {|x| {x}}", ()) // Function definitions are lambda assignments
"{(:$_let_$ :f {(:$$_lambda_$$ [x] {:x})})}", testToExpression("f(x)=x ? 1 : 0", "f = {|x| {x ? (1) : (0)}}", ())
~v="@{f: lambda(x=>internal code)}",
(),
)
testToExpression(
"f(x)=x",
"{(:$_let_$ :f (:$$_lambda_$$ [x] {:x}))}",
~v="@{f: lambda(x=>internal code)}",
(),
) // Function definitions are lambda assignments
testToExpression(
"f(x)=x ? 1 : 0",
"{(:$_let_$ :f (:$$_lambda_$$ [x] {(:$$_ternary_$$ :x 1 0)}))}",
~v="@{f: lambda(x=>internal code)}",
(),
)
}) })
describe("module", () => { describe("module", () => {
// testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ()) // testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ())
// Only.test("stdlibrary", () => { // Only.test("stdlibrary", () => {
// ReducerInterface_StdLib.internalStdLib // SquiggleLibrary_StdLib.stdLib
// ->IEvBindings // ->IEvBindings
// ->InternalExpressionValue.toString // ->Reducer_Value.toString
// ->expect // ->expect
// ->toBe("") // ->toBe("")
// }) // })
testToExpression("Math.pi", "{:Math.pi}", ~v="3.141592653589793", ()) testToExpression("Math.pi", "Math.pi", ~v="3.141592653589793", ())
}) })
}) })

View File

@ -5,92 +5,92 @@ describe("Peggy Types to Expression", () => {
describe("type of", () => { describe("type of", () => {
testToExpression( testToExpression(
"p: number", "p: number",
"{(:$_typeOf_$ :p #number)}", "{(:$_typeOf_$ :p #number); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {p: #number}}", // ~v="@{_typeReferences_: {p: #number}}",
(), (),
) )
}) })
describe("type alias", () => { describe("type alias", () => {
testToExpression( testToExpression(
"type index=number", "type index=number",
"{(:$_typeAlias_$ #index #number)}", "{(:$_typeAlias_$ #index #number); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeAliases_: {index: #number}}", // ~v="@{_typeAliases_: {index: #number}}",
(), (),
) )
}) })
describe("type or", () => { describe("type or", () => {
testToExpression( testToExpression(
"answer: number|string|distribution", "answer: number|string|distribution",
"{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ (#number #string #distribution))))}", "{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ #number #string #distribution))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {typeOr: [#number,#string,#distribution],typeTag: 'typeOr'}}}", // ~v="@{_typeReferences_: {answer: {typeOr: [#number,#string,#distribution],typeTag: 'typeOr'}}}",
(), (),
) )
}) })
describe("type function", () => { describe("type function", () => {
testToExpression( testToExpression(
"f: number=>number=>number", "f: number=>number=>number",
"{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ (#number #number #number))))}", "{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ #number #number #number))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {f: {inputs: [#number,#number],output: #number,typeTag: 'typeFunction'}}}", // ~v="@{_typeReferences_: {f: {inputs: [#number,#number],output: #number,typeTag: 'typeFunction'}}}",
(), (),
) )
testToExpression( testToExpression(
"f: number=>number", "f: number=>number",
"{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ (#number #number))))}", "{(:$_typeOf_$ :f (:$_typeFunction_$ (:$_constructArray_$ #number #number))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {f: {inputs: [#number],output: #number,typeTag: 'typeFunction'}}}", // ~v="@{_typeReferences_: {f: {inputs: [#number],output: #number,typeTag: 'typeFunction'}}}",
(), (),
) )
}) })
describe("high priority contract", () => { describe("high priority contract", () => {
testToExpression( testToExpression(
"answer: number<-min(1)<-max(100)|string", "answer: number<-min(1)<-max(100)|string",
"{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ ((:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 100) #string))))}", "{(:$_typeOf_$ :answer (:$_typeOr_$ (:$_constructArray_$ (:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 100) #string))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {typeOr: [{max: 100,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'},#string],typeTag: 'typeOr'}}}", // ~v="@{_typeReferences_: {answer: {typeOr: [{max: 100,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'},#string],typeTag: 'typeOr'}}}",
(), (),
) )
testToExpression( testToExpression(
"answer: number<-memberOf([1,3,5])", "answer: number<-memberOf([1,3,5])",
"{(:$_typeOf_$ :answer (:$_typeModifier_memberOf_$ #number (:$_constructArray_$ (1 3 5))))}", "{(:$_typeOf_$ :answer (:$_typeModifier_memberOf_$ #number (:$_constructArray_$ 1 3 5))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {memberOf: [1,3,5],typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", // ~v="@{_typeReferences_: {answer: {memberOf: [1,3,5],typeIdentifier: #number,typeTag: 'typeIdentifier'}}}",
(), (),
) )
testToExpression( testToExpression(
"answer: number<-min(1)", "answer: number<-min(1)",
"{(:$_typeOf_$ :answer (:$_typeModifier_min_$ #number 1))}", "{(:$_typeOf_$ :answer (:$_typeModifier_min_$ #number 1)); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", // ~v="@{_typeReferences_: {answer: {min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}",
(), (),
) )
testToExpression( testToExpression(
"answer: number<-max(10)", "answer: number<-max(10)",
"{(:$_typeOf_$ :answer (:$_typeModifier_max_$ #number 10))}", "{(:$_typeOf_$ :answer (:$_typeModifier_max_$ #number 10)); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {max: 10,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", // ~v="@{_typeReferences_: {answer: {max: 10,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}",
(), (),
) )
testToExpression( testToExpression(
"answer: number<-min(1)<-max(10)", "answer: number<-min(1)<-max(10)",
"{(:$_typeOf_$ :answer (:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 10))}", "{(:$_typeOf_$ :answer (:$_typeModifier_max_$ (:$_typeModifier_min_$ #number 1) 10)); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", // ~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}",
(), (),
) )
testToExpression( testToExpression(
"answer: number<-max(10)<-min(1)", "answer: number<-max(10)<-min(1)",
"{(:$_typeOf_$ :answer (:$_typeModifier_min_$ (:$_typeModifier_max_$ #number 10) 1))}", "{(:$_typeOf_$ :answer (:$_typeModifier_min_$ (:$_typeModifier_max_$ #number 10) 1)); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}", // ~v="@{_typeReferences_: {answer: {max: 10,min: 1,typeIdentifier: #number,typeTag: 'typeIdentifier'}}}",
(), (),
) )
}) })
describe("low priority contract", () => { describe("low priority contract", () => {
testToExpression( testToExpression(
"answer: number | string $ opaque", "answer: number | string $ opaque",
"{(:$_typeOf_$ :answer (:$_typeModifier_opaque_$ (:$_typeOr_$ (:$_constructArray_$ (#number #string)))))}", "{(:$_typeOf_$ :answer (:$_typeModifier_opaque_$ (:$_typeOr_$ (:$_constructArray_$ #number #string)))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeReferences_: {answer: {opaque: true,typeOr: [#number,#string],typeTag: 'typeOr'}}}", // ~v="@{_typeReferences_: {answer: {opaque: true,typeOr: [#number,#string],typeTag: 'typeOr'}}}",
(), (),
) )
}) })
describe("squiggle expressions in type contracts", () => { describe("squiggle expressions in type contracts", () => {
testToExpression( testToExpression(
"odds1 = [1,3,5]; odds2 = [7, 9]; type odds = number<-memberOf(concat(odds1, odds2))", "odds1 = [1,3,5]; odds2 = [7, 9]; type odds = number<-memberOf(concat(odds1, odds2))",
"{(:$_let_$ :odds1 {(:$_constructArray_$ (1 3 5))}); (:$_let_$ :odds2 {(:$_constructArray_$ (7 9))}); (:$_typeAlias_$ #odds (:$_typeModifier_memberOf_$ #number (:concat :odds1 :odds2)))}", "{(:$_let_$ :odds1 {(:$_constructArray_$ 1 3 5)}); (:$_let_$ :odds2 {(:$_constructArray_$ 7 9)}); (:$_typeAlias_$ #odds (:$_typeModifier_memberOf_$ #number (:concat :odds1 :odds2))); (:$_endOfOuterBlock_$ () ())}",
~v="@{_typeAliases_: {odds: {memberOf: [1,3,5,7,9],typeIdentifier: #number,typeTag: 'typeIdentifier'}},odds1: [1,3,5],odds2: [7,9]}", // ~v="@{_typeAliases_: {odds: {memberOf: [1,3,5,7,9],typeIdentifier: #number,typeTag: 'typeIdentifier'}},odds1: [1,3,5],odds2: [7,9]}",
(), (),
) )
}) })

View File

@ -3,18 +3,18 @@ open Reducer_Peggy_TestHelpers
describe("Peggy void", () => { describe("Peggy void", () => {
//literal //literal
testToExpression("()", "{()}", ~v="()", ()) testToExpression("()", "()", ~v="()", ())
testToExpression( testToExpression(
"fn()=1", "fn()=1",
"{(:$_let_$ :fn (:$$_lambda_$$ [_] {1}))}", "fn = {|_| {1}}",
~v="@{fn: lambda(_=>internal code)}", // ~v="@{fn: lambda(_=>internal code)}",
(), (),
) )
testToExpression("fn()=1; fn()", "{(:$_let_$ :fn (:$$_lambda_$$ [_] {1})); (:fn ())}", ~v="1", ()) testToExpression("fn()=1; fn()", "fn = {|_| {1}}; (fn)(())", ~v="1", ())
testToExpression( testToExpression(
"fn(a)=(); call fn(1)", "fn(a)=(); call fn(1)",
"{(:$_let_$ :fn (:$$_lambda_$$ [a] {()})); (:$_let_$ :_ {(:fn 1)})}", "fn = {|a| {()}}; _ = {(fn)(1)}",
~v="@{_: (),fn: lambda(a=>internal code)}", // ~v="@{_: (),fn: lambda(a=>internal code)}",
(), (),
) )
}) })

View File

@ -1,6 +1,5 @@
module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ExternalExpressionValue = ReducerInterface.ExternalExpressionValue
module ErrorValue = Reducer_ErrorValue
open Jest open Jest
open Expect open Expect
@ -8,30 +7,22 @@ open Expect
let unwrapRecord = rValue => let unwrapRecord = rValue =>
rValue->Belt.Result.flatMap(value => rValue->Belt.Result.flatMap(value =>
switch value { switch value {
| ExternalExpressionValue.EvRecord(aRecord) => Ok(aRecord) | Reducer_T.IEvRecord(aRecord) => Ok(aRecord)
| _ => ErrorValue.RETodo("TODO: External bindings must be returned")->Error | _ => SqError.Message.RETodo("TODO: Internal bindings must be returned")->Error
} }
) )
let expectParseToBe = (expr: string, answer: string) => let expectParseToBe = (code: string, answer: string) =>
Reducer.parse(expr)->ExpressionT.toStringResult->expect->toBe(answer) Expression.BackCompatible.parse(code)->ExpressionT.toStringResult->expect->toBe(answer)
let expectEvalToBe = (expr: string, answer: string) => let expectEvalToBe = (code: string, answer: string) =>
Reducer.evaluate(expr) Expression.BackCompatible.evaluateString(code)->Reducer_Value.toStringResult->expect->toBe(answer)
->Reducer_Helpers.rRemoveDefaultsExternal
->ExternalExpressionValue.toStringResult let expectEvalError = (code: string) =>
Expression.BackCompatible.evaluateString(code)
->Reducer_Value.toStringResult
->expect ->expect
->toBe(answer) ->toMatch("Error\\(")
let expectEvalError = (expr: string) =>
Reducer.evaluate(expr)->ExternalExpressionValue.toStringResult->expect->toMatch("Error\(")
let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) =>
Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~environment=None)
->Reducer_Helpers.rRemoveDefaultsExternal
->ExternalExpressionValue.toStringResult
->expect
->toBe(answer)
let testParseToBe = (expr, answer) => test(expr, () => expectParseToBe(expr, answer)) let testParseToBe = (expr, answer) => test(expr, () => expectParseToBe(expr, answer))
let testDescriptionParseToBe = (desc, expr, answer) => let testDescriptionParseToBe = (desc, expr, answer) =>
@ -40,18 +31,12 @@ let testDescriptionParseToBe = (desc, expr, answer) =>
let testEvalError = expr => test(expr, () => expectEvalError(expr)) let testEvalError = expr => test(expr, () => expectEvalError(expr))
let testEvalToBe = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer)) let testEvalToBe = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer))
let testDescriptionEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer)) let testDescriptionEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer))
let testEvalBindingsToBe = (expr, bindingsList, answer) =>
test(expr, () => expectEvalBindingsToBe(expr, bindingsList->Js.Dict.fromList, answer))
module MySkip = { module MySkip = {
let testParseToBe = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer)) let testParseToBe = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer))
let testEvalToBe = (expr, answer) => Skip.test(expr, () => expectEvalToBe(expr, answer)) let testEvalToBe = (expr, answer) => Skip.test(expr, () => expectEvalToBe(expr, answer))
let testEvalBindingsToBe = (expr, bindingsList, answer) =>
Skip.test(expr, () => expectEvalBindingsToBe(expr, bindingsList->Js.Dict.fromList, answer))
} }
module MyOnly = { module MyOnly = {
let testParseToBe = (expr, answer) => Only.test(expr, () => expectParseToBe(expr, answer)) let testParseToBe = (expr, answer) => Only.test(expr, () => expectParseToBe(expr, answer))
let testEvalToBe = (expr, answer) => Only.test(expr, () => expectEvalToBe(expr, answer)) let testEvalToBe = (expr, answer) => Only.test(expr, () => expectEvalToBe(expr, answer))
let testEvalBindingsToBe = (expr, bindingsList, answer) =>
Only.test(expr, () => expectEvalBindingsToBe(expr, bindingsList->Js.Dict.fromList, answer))
} }

View File

@ -1,88 +0,0 @@
open Jest
open Expect
module BindingsReplacer = Reducer_Expression_BindingsReplacer
module Expression = Reducer_Expression
// module ExpressionValue = ReducerInterface.ExpressionValue
module InternalExpressionValue = ReducerInterface.InternalExpressionValue
module ExpressionWithContext = Reducer_ExpressionWithContext
module Macro = Reducer_Expression_Macro
module T = Reducer_Expression_T
module Bindings = Reducer_Bindings
let testMacro_ = (
tester,
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedCode: string,
) => {
let bindings = Bindings.fromArray(bindArray)
tester(expr->T.toString, () =>
expr
->Macro.expandMacroCall(
bindings,
InternalExpressionValue.defaultEnvironment,
Expression.reduceExpression,
)
->ExpressionWithContext.toStringResult
->expect
->toEqual(expectedCode)
)
}
let testMacroEval_ = (
tester,
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedValue: string,
) => {
let bindings = Bindings.fromArray(bindArray)
tester(expr->T.toString, () =>
expr
->Macro.doMacroCall(
bindings,
InternalExpressionValue.defaultEnvironment,
Expression.reduceExpression,
)
->InternalExpressionValue.toStringResult
->expect
->toEqual(expectedValue)
)
}
let testMacro = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedExpr: string,
) => testMacro_(test, bindArray, expr, expectedExpr)
let testMacroEval = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedValue: string,
) => testMacroEval_(test, bindArray, expr, expectedValue)
module MySkip = {
let testMacro = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedExpr: string,
) => testMacro_(Skip.test, bindArray, expr, expectedExpr)
let testMacroEval = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedValue: string,
) => testMacroEval_(Skip.test, bindArray, expr, expectedValue)
}
module MyOnly = {
let testMacro = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedExpr: string,
) => testMacro_(Only.test, bindArray, expr, expectedExpr)
let testMacroEval = (
bindArray: array<(string, InternalExpressionValue.t)>,
expr: T.expression,
expectedValue: string,
) => testMacroEval_(Only.test, bindArray, expr, expectedValue)
}

View File

@ -1,52 +0,0 @@
module Expression = Reducer_Expression
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Bindings = Reducer_Bindings
module T = Reducer_Type_T
module TypeCompile = Reducer_Type_Compile
open Jest
open Expect
let myIevEval = (aTypeSourceCode: string) =>
TypeCompile.ievFromTypeExpression(aTypeSourceCode, Expression.reduceExpression)
let myIevEvalToString = (aTypeSourceCode: string) =>
myIevEval(aTypeSourceCode)->InternalExpressionValue.toStringResult
let myIevExpectEqual = (aTypeSourceCode, answer) =>
expect(myIevEvalToString(aTypeSourceCode))->toEqual(answer)
let myIevTest = (test, aTypeSourceCode, answer) =>
test(aTypeSourceCode, () => myIevExpectEqual(aTypeSourceCode, answer))
let myTypeEval = (aTypeSourceCode: string) =>
TypeCompile.fromTypeExpression(aTypeSourceCode, Expression.reduceExpression)
let myTypeEvalToString = (aTypeSourceCode: string) => myTypeEval(aTypeSourceCode)->T.toStringResult
let myTypeExpectEqual = (aTypeSourceCode, answer) =>
expect(myTypeEvalToString(aTypeSourceCode))->toEqual(answer)
let myTypeTest = (test, aTypeSourceCode, answer) =>
test(aTypeSourceCode, () => myTypeExpectEqual(aTypeSourceCode, answer))
// | ItTypeIdentifier(string)
myTypeTest(test, "number", "number")
myTypeTest(test, "(number)", "number")
// | ItModifiedType({modifiedType: iType})
myIevTest(test, "number<-min(0)", "Ok({min: 0,typeIdentifier: #number,typeTag: 'typeIdentifier'})")
myTypeTest(test, "number<-min(0)", "number<-min(0)")
// | ItTypeOr({typeOr: array<iType>})
myTypeTest(test, "number | string", "(number | string)")
// | ItTypeFunction({inputs: array<iType>, output: iType})
myTypeTest(test, "number => number => number", "(number => number => number)")
// | ItTypeArray({element: iType})
myIevTest(test, "[number]", "Ok({element: #number,typeTag: 'typeArray'})")
myTypeTest(test, "[number]", "[number]")
// | ItTypeTuple({elements: array<iType>})
myTypeTest(test, "[number, string]", "[number, string]")
// | ItTypeRecord({properties: Belt.Map.String.t<iType>})
myIevTest(
test,
"{age: number, name: string}",
"Ok({properties: {age: #number,name: #string},typeTag: 'typeRecord'})",
)
myTypeTest(test, "{age: number, name: string}", "{age: number, name: string}")

View File

@ -1,41 +0,0 @@
module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T
module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Bindings = Reducer_Bindings
module T = Reducer_Type_T
module TypeChecker = Reducer_Type_TypeChecker
open Jest
open Expect
let checkArgumentsSourceCode = (aTypeSourceCode: string, sourceCode: string): result<
'v,
ErrorValue.t,
> => {
let reducerFn = Expression.reduceExpression
let rResult =
Reducer.parse(sourceCode)->Belt.Result.flatMap(expr =>
reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment)
)
rResult->Belt.Result.flatMap(result =>
switch result {
| IEvArray(args) => TypeChecker.checkArguments(aTypeSourceCode, args, reducerFn)
| _ => Js.Exn.raiseError("Arguments has to be an array")
}
)
}
let myCheckArguments = (aTypeSourceCode: string, sourceCode: string): string =>
switch checkArgumentsSourceCode(aTypeSourceCode, sourceCode) {
| Ok(_) => "Ok"
| Error(error) => ErrorValue.errorToString(error)
}
let myCheckArgumentsExpectEqual = (aTypeSourceCode, sourceCode, answer) =>
expect(myCheckArguments(aTypeSourceCode, sourceCode))->toEqual(answer)
let myCheckArgumentsTest = (test, aTypeSourceCode, sourceCode, answer) =>
test(aTypeSourceCode, () => myCheckArgumentsExpectEqual(aTypeSourceCode, sourceCode, answer))
myCheckArgumentsTest(test, "number=>number=>number", "[1,2]", "Ok")

View File

@ -1,70 +0,0 @@
module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T
module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Bindings = Reducer_Bindings
module T = Reducer_Type_T
module TypeChecker = Reducer_Type_TypeChecker
open Jest
open Expect
// In development, you are expected to use TypeChecker.isTypeOf(aTypeSourceCode, result, reducerFn).
// isTypeOfSourceCode is written to use strings instead of expression values.
let isTypeOfSourceCode = (aTypeSourceCode: string, sourceCode: string): result<
'v,
ErrorValue.t,
> => {
let reducerFn = Expression.reduceExpression
let rResult =
Reducer.parse(sourceCode)->Belt.Result.flatMap(expr =>
reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment)
)
rResult->Belt.Result.flatMap(result => TypeChecker.isTypeOf(aTypeSourceCode, result, reducerFn))
}
let myTypeCheck = (aTypeSourceCode: string, sourceCode: string): string =>
switch isTypeOfSourceCode(aTypeSourceCode, sourceCode) {
| Ok(_) => "Ok"
| Error(error) => ErrorValue.errorToString(error)
}
let myTypeCheckExpectEqual = (aTypeSourceCode, sourceCode, answer) =>
expect(myTypeCheck(aTypeSourceCode, sourceCode))->toEqual(answer)
let myTypeCheckTest = (test, aTypeSourceCode, sourceCode, answer) =>
test(aTypeSourceCode, () => myTypeCheckExpectEqual(aTypeSourceCode, sourceCode, answer))
myTypeCheckTest(test, "number", "1", "Ok")
myTypeCheckTest(test, "number", "'2'", "Expected type: number but got: '2'")
myTypeCheckTest(test, "string", "3", "Expected type: string but got: 3")
myTypeCheckTest(test, "string", "'a'", "Ok")
myTypeCheckTest(test, "[number]", "[1,2,3]", "Ok")
myTypeCheckTest(test, "[number]", "['a','a','a']", "Expected type: number but got: 'a'")
myTypeCheckTest(test, "[number]", "[1,'a',3]", "Expected type: number but got: 'a'")
myTypeCheckTest(test, "[number, string]", "[1,'a']", "Ok")
myTypeCheckTest(test, "[number, string]", "[1, 2]", "Expected type: string but got: 2")
myTypeCheckTest(
test,
"[number, string, string]",
"[1,'a']",
"Expected type: [number, string, string] but got: [1,'a']",
)
myTypeCheckTest(
test,
"[number, string]",
"[1,'a', 3]",
"Expected type: [number, string] but got: [1,'a',3]",
)
myTypeCheckTest(test, "{age: number, name: string}", "{age: 1, name: 'a'}", "Ok")
myTypeCheckTest(
test,
"{age: number, name: string}",
"{age: 1, name: 'a', job: 'IT'}",
"Expected type: {age: number, name: string} but got: {age: 1,job: 'IT',name: 'a'}",
)
myTypeCheckTest(test, "number | string", "1", "Ok")
myTypeCheckTest(test, "date | string", "1", "Expected type: (date | string) but got: 1")
myTypeCheckTest(test, "number<-min(10)", "10", "Ok")
myTypeCheckTest(test, "number<-min(10)", "0", "Expected type: number<-min(10) but got: 0")

View File

@ -0,0 +1,14 @@
open Jest
open Expect
describe("ExpressionValue", () => {
test("argsToString", () =>
expect([IEvNumber(1.), IEvString("a")]->Reducer_Value.argsToString)->toBe("1,'a'")
)
test("toStringFunctionCall", () =>
expect(("fn", [IEvNumber(1.), IEvString("a")])->Reducer_Value.toStringFunctionCall)->toBe(
"fn(1,'a')",
)
)
})

View File

@ -0,0 +1,13 @@
open Jest
open Reducer_Peggy_TestHelpers
describe("Construct Array", () => {
testToExpression("[1,2]", "[1, 2]", ~v="[1,2]", ())
testToExpression("[]", "[]", ~v="[]", ())
testToExpression(
"f(x)=x; g(x)=x; [f, g]",
"f = {|x| {x}}; g = {|x| {x}}; [f, g]",
~v="[lambda(x=>internal code),lambda(x=>internal code)]",
(),
)
})

View File

@ -1,14 +0,0 @@
open Jest
open Reducer_TestHelpers
describe("Eval with Bindings", () => {
testEvalBindingsToBe("x", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(1)")
testEvalBindingsToBe("x+1", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(2)")
testParseToBe("y = x+1; y", "Ok({(:$_let_$ :y {(:add :x 1)}); :y})")
testEvalBindingsToBe("y = x+1; y", list{("x", ExternalExpressionValue.EvNumber(1.))}, "Ok(2)")
testEvalBindingsToBe(
"y = x+1",
list{("x", ExternalExpressionValue.EvNumber(1.))},
"Ok(@{x: 1,y: 2})",
)
})

View File

@ -2,11 +2,15 @@ open Jest
open Reducer_TestHelpers open Reducer_TestHelpers
describe("Parse function assignment", () => { describe("Parse function assignment", () => {
testParseToBe("f(x)=x", "Ok({(:$_let_$ :f (:$$_lambda_$$ [x] {:x}))})") testParseToBe("f(x)=x", "Ok(f = {|x| {x}})")
testParseToBe("f(x)=2*x", "Ok({(:$_let_$ :f (:$$_lambda_$$ [x] {(:multiply 2 :x)}))})") testParseToBe("f(x)=2*x", "Ok(f = {|x| {(multiply)(2, x)}})")
//MathJs does not allow blocks in function definitions //MathJs does not allow blocks in function definitions
}) })
describe("Evaluate function assignment", () => { describe("Evaluate function assignment", () => {
testEvalToBe("f(x)=x; f(1)", "Ok(1)") testEvalToBe("f(x)=x; f(1)", "Ok(1)")
}) })
describe("Shadowing", () => {
testEvalToBe("x = 5; f(y) = x*y; x = 6; f(2)", "Ok(10)")
})

View File

@ -34,38 +34,29 @@ describe("symbol not defined", () => {
testEvalToBe("f(x)=x(y); f(f)", "Error(y is not defined)") testEvalToBe("f(x)=x(y); f(f)", "Error(y is not defined)")
testEvalToBe("f(x)=x; f(f)", "Ok(lambda(x=>internal code))") testEvalToBe("f(x)=x; f(f)", "Ok(lambda(x=>internal code))")
testEvalToBe("f(x)=x(y); f(z)", "Error(z is not defined)") testEvalToBe("f(x)=x(y); f(z)", "Error(z is not defined)")
testEvalToBe("f(x)=x(y); f(2)", "Error(2 is not a function)") testEvalToBe("f(x)=x(y); f(2)", "Error(y is not defined)")
testEvalToBe("f(x)=x(1); f(2)", "Error(2 is not a function)") testEvalToBe("f(x)=x(1); f(2)", "Error(2 is not a function)")
}) })
describe("call and bindings", () => { describe("call and bindings", () => {
testEvalToBe("f(x)=x+1", "Ok(@{f: lambda(x=>internal code)})") testEvalToBe("f(x)=x+1; f(0)", "Ok(1)")
testEvalToBe("f(x)=x+1; f(1)", "Ok(2)") testEvalToBe("f(x)=x+1; f(1)", "Ok(2)")
testEvalToBe("f=1;y=2", "Ok(@{f: 1,y: 2})") testEvalToBe("f=1;y=2", "Ok(())")
testEvalToBe("f(x)=x+1; y=f(1)", "Ok(@{f: lambda(x=>internal code),y: 2})") testEvalToBe("f(x)=x+1; y=f(1); y", "Ok(2)")
testEvalToBe("f(x)=x+1; y=f(1); f(1)", "Ok(2)") testEvalToBe("f(x)=x+1; y=f(1); f(1)", "Ok(2)")
testEvalToBe("f(x)=x+1; y=f(1); z=f(1)", "Ok(@{f: lambda(x=>internal code),y: 2,z: 2})") testEvalToBe("f(x)=x+1; y=f(1); z=f(1); z", "Ok(2)")
testEvalToBe( testEvalToBe("f(x)=x+1; g(x)=f(x)+1; g(0)", "Ok(2)")
"f(x)=x+1; g(x)=f(x)+1", testParseToBe("f=99; g(x)=f; g(2)", "Ok(f = {99}; g = {|x| {f}}; (g)(2))")
"Ok(@{f: lambda(x=>internal code),g: lambda(x=>internal code)})",
)
testParseToBe(
"f=99; g(x)=f; g(2)",
"Ok({(:$_let_$ :f {99}); (:$_let_$ :g (:$$_lambda_$$ [x] {:f})); (:g 2)})",
)
testEvalToBe("f=99; g(x)=f; g(2)", "Ok(99)") testEvalToBe("f=99; g(x)=f; g(2)", "Ok(99)")
testEvalToBe("f(x)=x; g(x)=f(x); g(2)", "Ok(2)") testEvalToBe("f(x)=x; g(x)=f(x); g(2)", "Ok(2)")
testEvalToBe( testEvalToBe("f(x)=x+1; g(x)=f(x)+1; y=g(2); y", "Ok(4)")
"f(x)=x+1; g(x)=f(x)+1; y=g(2)",
"Ok(@{f: lambda(x=>internal code),g: lambda(x=>internal code),y: 4})",
)
testEvalToBe("f(x)=x+1; g(x)=f(x)+1; g(2)", "Ok(4)") testEvalToBe("f(x)=x+1; g(x)=f(x)+1; g(2)", "Ok(4)")
}) })
describe("function tricks", () => { describe("function tricks", () => {
testEvalError("f(x)=f(y)=2; f(2)") //Error because chain assignment is not allowed testEvalError("f(x)=f(y)=2; f(2)") //Error because chain assignment is not allowed
testEvalToBe("y=2;g(x)=y+1;g(2)", "Ok(3)") testEvalToBe("y=2;g(x)=y+1;g(2)", "Ok(3)")
testEvalToBe("y=2;g(x)=inspect(y)+1", "Ok(@{g: lambda(x=>internal code),y: 2})") testEvalToBe("y=2;g(x)=inspect(y)+1;y", "Ok(2)")
MySkip.testEvalToBe("f(x) = x(x); f(f)", "????") // TODO: Infinite loop. Any solution? Catching proper exception or timeout? MySkip.testEvalToBe("f(x) = x(x); f(f)", "????") // TODO: Infinite loop. Any solution? Catching proper exception or timeout?
MySkip.testEvalToBe("f(x, x)=x+x; f(1,2)", "????") // TODO: Duplicate parameters MySkip.testEvalToBe("f(x, x)=x+x; f(1,2)", "????") // TODO: Duplicate parameters
testEvalToBe("myadd(x,y)=x+y; z=myadd; z", "Ok(lambda(x,y=>internal code))") testEvalToBe("myadd(x,y)=x+y; z=myadd; z", "Ok(lambda(x,y=>internal code))")
@ -73,10 +64,7 @@ describe("function tricks", () => {
}) })
describe("lambda in structures", () => { describe("lambda in structures", () => {
testEvalToBe( testEvalToBe("myadd(x,y)=x+y; z=[myadd]", "Ok(())")
"myadd(x,y)=x+y; z=[myadd]",
"Ok(@{myadd: lambda(x,y=>internal code),z: [lambda(x,y=>internal code)]})",
)
testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0]", "Ok(lambda(x,y=>internal code))") testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0]", "Ok(lambda(x,y=>internal code))")
testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0](3,2)", "Ok(5)") testEvalToBe("myadd(x,y)=x+y; z=[myadd]; z[0](3,2)", "Ok(5)")
testEvalToBe("myaddd(x,y)=x+y; z={x: myaddd}; z", "Ok({x: lambda(x,y=>internal code)})") testEvalToBe("myaddd(x,y)=x+y; z={x: myaddd}; z", "Ok({x: lambda(x,y=>internal code)})")

View File

@ -5,3 +5,7 @@ Skip.describe("map reduce (sam)", () => {
testEvalToBe("addone(x)=x+1; map(2, addone)", "Error???") testEvalToBe("addone(x)=x+1; map(2, addone)", "Error???")
testEvalToBe("addone(x)=x+1; map(2, {x: addone})", "Error???") testEvalToBe("addone(x)=x+1; map(2, {x: addone})", "Error???")
}) })
describe("map", () => {
testEvalToBe("arr=[1,2,3]; map(arr, {|x| x*2})", "Ok([2,4,6])")
})

View File

@ -2,7 +2,7 @@ open Jest
open Reducer_TestHelpers open Reducer_TestHelpers
describe("Parse ternary operator", () => { describe("Parse ternary operator", () => {
testParseToBe("true ? 'YES' : 'NO'", "Ok({(:$$_ternary_$$ true 'YES' 'NO')})") testParseToBe("true ? 'YES' : 'NO'", "Ok(true ? ('YES') : ('NO'))")
}) })
describe("Evaluate ternary operator", () => { describe("Evaluate ternary operator", () => {

View File

@ -2,19 +2,29 @@ open Jest
open Reducer_TestHelpers open Reducer_TestHelpers
describe("eval", () => { describe("eval", () => {
// All MathJs operators and functions are builtin for string, float and boolean
// .e.g + - / * > >= < <= == /= not and or
// See https://mathjs.org/docs/reference/functions.html
describe("expressions", () => { describe("expressions", () => {
testEvalToBe("1", "Ok(1)") testEvalToBe("1", "Ok(1)")
testEvalToBe("-1", "Ok(-1)")
testEvalToBe("1-1", "Ok(0)")
testEvalToBe("1+2", "Ok(3)") testEvalToBe("1+2", "Ok(3)")
testEvalToBe("(1+2)*3", "Ok(9)") testEvalToBe("(1+2)*3", "Ok(9)")
testEvalToBe("2>1", "Ok(true)") testEvalToBe("2>1", "Ok(true)")
testEvalToBe("concat('a ', 'b')", "Ok('a b')") testEvalToBe("concat('a ', 'b')", "Ok('a b')")
testEvalToBe("concat([3,4], [5,6,7])", "Ok([3,4,5,6,7])")
testEvalToBe("log(10)", "Ok(2.302585092994046)") testEvalToBe("log(10)", "Ok(2.302585092994046)")
testEvalToBe("cos(10)", "Ok(-0.8390715290764524)") testEvalToBe("Math.cos(10)", "Ok(-0.8390715290764524)")
// TODO more built ins // TODO more built ins
}) })
describe("missing function", () => {
testEvalToBe("testZadanga(1)", "Error(testZadanga is not defined)")
testEvalToBe(
"arr = [normal(3,2)]; map(arr, zarathsuzaWasHere)",
"Error(zarathsuzaWasHere is not defined)",
)
})
describe("arrays", () => { describe("arrays", () => {
test("empty array", () => expectEvalToBe("[]", "Ok([])")) test("empty array", () => expectEvalToBe("[]", "Ok([])"))
testEvalToBe("[1, 2, 3]", "Ok([1,2,3])") testEvalToBe("[1, 2, 3]", "Ok([1,2,3])")
@ -27,14 +37,16 @@ describe("eval", () => {
test("index", () => expectEvalToBe("r = {a: 1}; r.a", "Ok(1)")) test("index", () => expectEvalToBe("r = {a: 1}; r.a", "Ok(1)"))
test("index", () => expectEvalToBe("r = {a: 1}; r.b", "Error(Record property not found: b)")) test("index", () => expectEvalToBe("r = {a: 1}; r.b", "Error(Record property not found: b)"))
testEvalError("{a: 1}.b") // invalid syntax testEvalError("{a: 1}.b") // invalid syntax
test("always the same property ending", () => test(
expectEvalToBe( "always the same property ending",
`{ () =>
expectEvalToBe(
`{
a: 1, a: 1,
b: 2, b: 2,
}`, }`,
"Ok({a: 1,b: 2})", "Ok({a: 1,b: 2})",
) ),
) )
}) })
@ -48,7 +60,11 @@ describe("eval", () => {
testEvalToBe("x=1; y=x+1; y+1", "Ok(3)") testEvalToBe("x=1; y=x+1; y+1", "Ok(3)")
testEvalError("1; x=1") testEvalError("1; x=1")
testEvalError("1; 1") testEvalError("1; 1")
testEvalToBe("x=1; x=1", "Ok(@{x: 1})") testEvalToBe("x=1; x=1; x", "Ok(1)")
})
describe("blocks", () => {
testEvalToBe("x = { y = { z = 5; z * 2 }; y + 3 }; x", "Ok(13)")
}) })
}) })
@ -64,3 +80,33 @@ describe("test exceptions", () => {
// "Error(TODO: unhandled rescript exception)", // "Error(TODO: unhandled rescript exception)",
// ) // )
}) })
describe("stacktraces", () => {
test("nested calls", () => {
open Expect
let error =
Expression.BackCompatible.evaluateString(`
f(x) = {
y = "a"
x + y
}
g = {|x| f(x)}
h(x) = g(x)
h(5)
`)
->E.R.getError
->E.O2.toExn("oops")
->SqError.toStringWithStackTrace
expect(
error,
)->toBe(`Error: There are function matches for add(), but with different arguments: [add(number, number)]; [add(distribution, number)]; [add(number, distribution)]; [add(distribution, distribution)]; [add(date, duration)]; [add(duration, duration)]
Stack trace:
f at line 4, column 5
g at line 6, column 12
h at line 7, column 10
<top> at line 8, column 3
`)
})
})

Some files were not shown because too many files have changed in this diff Show More