Merge branch 'develop' into error-locations

This commit is contained in:
Vyacheslav Matyukhin 2022-10-08 04:12:19 +04:00
commit d5f0a6bcf8
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
17 changed files with 63 additions and 40 deletions

2
.github/CODEOWNERS vendored
View File

@ -24,7 +24,7 @@
*.json @quinn-dougherty @Hazelfire @berekuk @OAGr *.json @quinn-dougherty @Hazelfire @berekuk @OAGr
*.y*ml @quinn-dougherty @berekuk @OAGr *.y*ml @quinn-dougherty @berekuk @OAGr
*.config.js @Hazelfire @berekuk @OAGr *.config.js @Hazelfire @berekuk @OAGr
netlify.toml @quinn-dougherty @OAGr @berekuk @Hazelfire vercel.json @OAGr @berekuk @Hazelfire
# Documentation # Documentation
*.md @quinn-dougherty @OAGr @Hazelfire *.md @quinn-dougherty @OAGr @Hazelfire

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

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

@ -0,0 +1,6 @@
{
"buildCommand": "cd ../squiggle-lang && yarn build && cd ../components && yarn build",
"outputDirectory": "storybook-static",
"installCommand": "cd ../../ && yarn",
"ignoreCommand": "git diff --quiet $VERCEL_GIT_PREVIOUS_SHA $VERCEL_GIT_COMMIT_SHA . ../squiggle-lang"
}

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.
*/ */

View File

@ -10,6 +10,8 @@ let examples = E.A.to_list(FunctionRegistry_Core.Registry.allExamples(registry))
describe("FunctionRegistry Library", () => { describe("FunctionRegistry Library", () => {
describe("Regular tests", () => { describe("Regular tests", () => {
testEvalToBe("List.length([3,5,8])", "Ok(3)")
testEvalToBe("List.length([])", "Ok(0)")
testEvalToBe("List.make(3, 'HI')", "Ok(['HI','HI','HI'])") testEvalToBe("List.make(3, 'HI')", "Ok(['HI','HI','HI'])")
testEvalToBe("make(3, 'HI')", "Error(make is not defined)") testEvalToBe("make(3, 'HI')", "Error(make is not defined)")
testEvalToBe("List.upTo(1,3)", "Ok([1,2,3])") testEvalToBe("List.upTo(1,3)", "Ok([1,2,3])")
@ -80,6 +82,10 @@ describe("FunctionRegistry Library", () => {
"SampleSet.toList(SampleSet.mapN([SampleSet.fromList([1,2,3,4,5,6]), SampleSet.fromList([6, 5, 4, 3, 2, 1])], {|x| x[0] > x[1] ? x[0] : x[1]}))", "SampleSet.toList(SampleSet.mapN([SampleSet.fromList([1,2,3,4,5,6]), SampleSet.fromList([6, 5, 4, 3, 2, 1])], {|x| x[0] > x[1] ? x[0] : x[1]}))",
"Ok([6,5,4,4,5,6])", "Ok([6,5,4,4,5,6])",
) )
testEvalToBe(
"SampleSet.fromList([1, 2, 3])",
"Error(Error: Too few samples when constructing sample set)",
)
testEvalToBe("Dict.merge({a: 1, b: 2}, {b: 3, c: 4, d: 5})", "Ok({a: 1,b: 3,c: 4,d: 5})") testEvalToBe("Dict.merge({a: 1, b: 2}, {b: 3, c: 4, d: 5})", "Ok({a: 1,b: 3,c: 4,d: 5})")
testEvalToBe( testEvalToBe(

View File

@ -4,13 +4,6 @@ module Error = {
type sampleSetError = type sampleSetError =
TooFewSamples | NonNumericInput(string) | OperationError(Operation.operationError) TooFewSamples | NonNumericInput(string) | OperationError(Operation.operationError)
let sampleSetErrorToString = (err: sampleSetError): string =>
switch err {
| TooFewSamples => "Too few samples when constructing sample set"
| NonNumericInput(err) => `Found a non-number in input: ${err}`
| OperationError(err) => Operation.Error.toString(err)
}
@genType @genType
type pointsetConversionError = TooFewSamplesForConversionToPointSet type pointsetConversionError = TooFewSamplesForConversionToPointSet

View File

@ -5,6 +5,10 @@ let nameSpace = "List"
let requiresNamespace = true let requiresNamespace = true
module Internals = { module Internals = {
let length = (v: array<Reducer_T.value>): Reducer_T.value => IEvNumber(
Belt.Int.toFloat(Array.length(v)),
)
let makeFromNumber = (n: float, value: Reducer_T.value): Reducer_T.value => IEvArray( let makeFromNumber = (n: float, value: Reducer_T.value): Reducer_T.value => IEvArray(
Belt.Array.make(E.Float.toInt(n), value), Belt.Array.make(E.Float.toInt(n), value),
) )
@ -75,6 +79,26 @@ module Internals = {
} }
let library = [ let library = [
Function.make(
~name="length",
~nameSpace,
~output=EvtNumber,
~requiresNamespace=true,
~examples=[`List.length([1,4,5])`],
~definitions=[
FnDefinition.make(
~name="length",
~inputs=[FRTypeArray(FRTypeAny)],
~run=(inputs, _, _) =>
switch inputs {
| [IEvArray(array)] => Internals.length(array)->Ok
| _ => Error(impossibleError)
},
(),
),
],
(),
),
Function.make( Function.make(
~name="make", ~name="make",
~nameSpace, ~nameSpace,

View File

@ -115,7 +115,7 @@ let libaryBase = [
~run=(inputs, _, _) => { ~run=(inputs, _, _) => {
let sampleSet = let sampleSet =
inputs->Prepare.ToTypedArray.numbers inputs->Prepare.ToTypedArray.numbers
|> E.R2.bind(r => SampleSetDist.make(r)->E.R2.errMap(_ => "AM I HERE? WHYERE AMI??")) |> E.R2.bind(r => SampleSetDist.make(r)->E.R2.errMap(SampleSetDist.Error.toString))
sampleSet sampleSet
->E.R2.fmap(Wrappers.sampleSet) ->E.R2.fmap(Wrappers.sampleSet)
->E.R2.fmap(Wrappers.evDistribution) ->E.R2.fmap(Wrappers.evDistribution)

View File

@ -181,7 +181,7 @@ The `sample(distribution)` samples a given distribution.
## Converting between distribution formats ## Converting between distribution formats
Recall the [three formats of distributions](https://develop--squiggle-documentation.netlify.app/docs/Discussions/Three-Types-Of-Distributions). We can force any distribution into `SampleSet` format Recall the [three formats of distributions](/docs/Discussions/Three-Formats-Of-Distributions). We can force any distribution into `SampleSet` format
<SquiggleEditor defaultCode="SampleSet.fromDist(normal(5, 10))" /> <SquiggleEditor defaultCode="SampleSet.fromDist(normal(5, 10))" />

View File

@ -86,11 +86,11 @@ c = 5 to 10 // namespace not required
""`} ""`}
/> />
## Number Prefixes ## Number Suffixes
Numbers support a few scientific notation prefixes. Numbers support a few scientific notation suffixes.
| prefix | multiplier | | suffix | multiplier |
| ------ | ---------- | | ------ | ---------- |
| n | 10^-9 | | n | 10^-9 |
| m | 10^-3 | | m | 10^-3 |

View File

@ -22,7 +22,7 @@ Types are available for both packages.
This documentation uses `@quri/squiggle-components` frequently. This documentation uses `@quri/squiggle-components` frequently.
We host [a storybook](https://squiggle-components.netlify.app/) with details We host [a storybook](https://components.squiggle-language.com) with details
and usage of each of the components made available. and usage of each of the components made available.
## [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=QURI.vscode-squiggle) ![npm version](https://vsmarketplacebadge.apphb.com/version/QURI.vscode-squiggle.svg) ## [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=QURI.vscode-squiggle) ![npm version](https://vsmarketplacebadge.apphb.com/version/QURI.vscode-squiggle.svg)

View File

@ -75,7 +75,7 @@ There's a simple [VS Code extension](https://marketplace.visualstudio.com/items?
Squiggle is built using [Rescript](https://rescript-lang.org/), and is accessible via a simple Typescript library. You can use this library to either run Squiggle code in full, or to call select specific functions within Squiggle (though this latter functionality is very minimal). Squiggle is built using [Rescript](https://rescript-lang.org/), and is accessible via a simple Typescript library. You can use this library to either run Squiggle code in full, or to call select specific functions within Squiggle (though this latter functionality is very minimal).
**[React Components Library](https://www.npmjs.com/package/@quri/squiggle-components)** **[React Components Library](https://www.npmjs.com/package/@quri/squiggle-components)**
All of the components used in the playground and documentation are available in a separate component NPM repo. You can see the full Storybook of components [here](https://squiggle-components.netlify.app). All of the components used in the playground and documentation are available in a separate component NPM repo. You can see the full Storybook of components [here](https://components.squiggle-language.com).
**[Observable](https://observablehq.com/@hazelfire/squiggle)** **[Observable](https://observablehq.com/@hazelfire/squiggle)**
You can use Squiggle Components in Observable notebooks. Sam Nolan put together an exportable [Observable Notebook](https://observablehq.com/@hazelfire/squiggle) of the key components that you can directly import and use in your Observable notebooks. You can use Squiggle Components in Observable notebooks. Sam Nolan put together an exportable [Observable Notebook](https://observablehq.com/@hazelfire/squiggle) of the key components that you can directly import and use in your Observable notebooks.

View File

@ -76,6 +76,10 @@ const config = {
// //... other Algolia params // //... other Algolia params
// }, // },
colorMode: {
// squiggle playground is not compatible with dark mode yet, see https://github.com/quantified-uncertainty/squiggle/issues/1192
disableSwitch: true,
},
navbar: { navbar: {
title: "Squiggle", title: "Squiggle",
hideOnScroll: true, hideOnScroll: true,

View File

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

View File

@ -0,0 +1,6 @@
{
"buildCommand": "cd ../squiggle-lang && yarn build && cd ../components && yarn build && cd ../website && yarn build",
"framework": "docusaurus-2",
"installCommand": "cd ../../ && yarn",
"ignoreCommand": "git diff --quiet $VERCEL_GIT_PREVIOUS_SHA $VERCEL_GIT_COMMIT_SHA ../squiggle-lang ../components ."
}