diff --git a/packages/squiggle-lang/__tests__/DistTypes__Test.res b/packages/squiggle-lang/__tests__/DistTypes__Test.res deleted file mode 100644 index fb09d6d9..00000000 --- a/packages/squiggle-lang/__tests__/DistTypes__Test.res +++ /dev/null @@ -1,89 +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("PointSetTypes", () => - describe("Domain", () => { - let makeComplete = (yPoint, expectation) => - makeTest( - "With input: " ++ Js.Float.toString(yPoint), - PointSetTypes.Domain.yPointToSubYPoint(Complete, yPoint), - expectation, - ) - let makeSingle = (direction: [#left | #right], excludingProbabilityMass, yPoint, expectation) => - makeTest( - "Excluding: " ++ - (Js.Float.toString(excludingProbabilityMass) ++ - (" and yPoint: " ++ Js.Float.toString(yPoint))), - PointSetTypes.Domain.yPointToSubYPoint( - direction == #left - ? LeftLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}) - : RightLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}), - yPoint, - ), - expectation, - ) - let makeDouble = (domain, yPoint, expectation) => - makeTest("Excluding: limits", PointSetTypes.Domain.yPointToSubYPoint(domain, yPoint), expectation) - - describe("With Complete Domain", () => { - makeComplete(0.0, Some(0.0)) - makeComplete(0.6, Some(0.6)) - makeComplete(1.0, Some(1.0)) - }) - describe("With Left Limit", () => { - makeSingle(#left, 0.5, 1.0, Some(1.0)) - makeSingle(#left, 0.5, 0.75, Some(0.5)) - makeSingle(#left, 0.8, 0.9, Some(0.5)) - makeSingle(#left, 0.5, 0.4, None) - makeSingle(#left, 0.5, 0.5, Some(0.0)) - }) - describe("With Right Limit", () => { - makeSingle(#right, 0.5, 1.0, None) - makeSingle(#right, 0.5, 0.25, Some(0.5)) - makeSingle(#right, 0.8, 0.5, None) - makeSingle(#right, 0.2, 0.2, Some(0.25)) - makeSingle(#right, 0.5, 0.5, Some(1.0)) - makeSingle(#right, 0.5, 0.0, Some(0.0)) - makeSingle(#right, 0.5, 0.5, Some(1.0)) - }) - describe("With Left and Right Limit", () => { - makeDouble( - LeftAndRightLimited( - {excludingProbabilityMass: 0.25, xPoint: 3.0}, - {excludingProbabilityMass: 0.25, xPoint: 10.0}, - ), - 0.5, - Some(0.5), - ) - makeDouble( - LeftAndRightLimited( - {excludingProbabilityMass: 0.1, xPoint: 3.0}, - {excludingProbabilityMass: 0.1, xPoint: 10.0}, - ), - 0.2, - Some(0.125), - ) - makeDouble( - LeftAndRightLimited( - {excludingProbabilityMass: 0.1, xPoint: 3.0}, - {excludingProbabilityMass: 0.1, xPoint: 10.0}, - ), - 0.1, - Some(0.0), - ) - makeDouble( - LeftAndRightLimited( - {excludingProbabilityMass: 0.1, xPoint: 3.0}, - {excludingProbabilityMass: 0.1, xPoint: 10.0}, - ), - 0.05, - None, - ) - }) - }) -) diff --git a/packages/squiggle-lang/__tests__/GenericDist/GenericOperation__Test.res b/packages/squiggle-lang/__tests__/GenericDist/GenericOperation__Test.res index 90d5a67c..aa921892 100644 --- a/packages/squiggle-lang/__tests__/GenericDist/GenericOperation__Test.res +++ b/packages/squiggle-lang/__tests__/GenericDist/GenericOperation__Test.res @@ -1,7 +1,7 @@ open Jest open Expect -let env: GenericDist_GenericOperation.env = { +let env: DistributionOperation.env = { sampleCount: 100, xyPointLength: 100, } @@ -11,9 +11,9 @@ let normalDist10: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 10.0, let normalDist20: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 20.0, stdev: 2.0})) let uniformDist: GenericDist_Types.genericDist = Symbolic(#Uniform({low: 9.0, high: 10.0})) -let {toFloat, toDist, toString, toError} = module(GenericDist_GenericOperation.Output) -let {run} = module(GenericDist_GenericOperation) -let {fmap} = module(GenericDist_GenericOperation.Output) +let {toFloat, toDist, toString, toError} = module(DistributionOperation.Output) +let {run} = module(DistributionOperation) +let {fmap} = module(DistributionOperation.Output) let run = run(~env) let outputMap = fmap(~env) let toExt: option<'a> => 'a = E.O.toExt( @@ -29,7 +29,7 @@ describe("normalize", () => { describe("mean", () => { test("for a normal distribution", () => { - let result = GenericDist_GenericOperation.run(~env, FromDist(ToFloat(#Mean), normalDist)) + let result = DistributionOperation.run(~env, FromDist(ToFloat(#Mean), normalDist)) expect(result)->toEqual(Float(5.0)) }) }) diff --git a/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res new file mode 100644 index 00000000..85d80919 --- /dev/null +++ b/packages/squiggle-lang/__tests__/ReducerInterface/ReducerInterface_Distribution_test.res @@ -0,0 +1,125 @@ +open Jest + +let testSkip: (bool, string, unit => assertion) => unit = (skip: bool) => + if skip { + Skip.test + } else { + test + } +let testEval = (~skip=false, str, result) => + testSkip(skip)(str, () => Reducer_TestHelpers.expectEvalToBe(str, result)) +let testParse = (~skip=false, str, result) => + testSkip(skip)(str, () => Reducer_TestHelpers.expectParseToBe(str, result)) + +describe("eval on distribution functions", () => { + describe("normal distribution", () => { + testEval("normal(5,2)", "Ok(Normal(5,2))") + }) + describe("lognormal distribution", () => { + testEval("lognormal(5,2)", "Ok(Lognormal(5,2))") + }) + describe("unaryMinus", () => { + testEval("mean(-normal(5,2))", "Ok(-5.002887370380851)") + }) + describe("to", () => { + testEval("5 to 2", "Error(TODO: Low value must be less than high value.)") + testEval("to(2,5)", "Ok(Lognormal(1.1512925464970227,0.278507821238345))") + testEval("to(-2,2)", "Ok(Normal(0,1.215913388057542))") + }) + describe("mean", () => { + testEval("mean(normal(5,2))", "Ok(5)") + testEval("mean(lognormal(1,2))", "Ok(20.085536923187668)") + }) + describe("normalize", () => { + testEval("normalize(normal(5,2))", "Ok(Normal(5,2))") + }) + describe("toPointSet", () => { + testEval("toPointSet(normal(5,2))", "Ok(Point Set Distribution)") + }) + describe("toSampleSet", () => { + testEval("toSampleSet(normal(5,2), 100)", "Ok(Sample Set Distribution)") + }) + describe("add", () => { + testEval("add(normal(5,2), normal(10,2))", "Ok(Normal(15,2.8284271247461903))") + testEval("add(normal(5,2), lognormal(10,2))", "Ok(Sample Set Distribution)") + testEval("add(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("add(3, normal(5,2))", "Ok(Point Set Distribution)") + testEval("3+normal(5,2)", "Ok(Point Set Distribution)") + testEval("normal(5,2)+3", "Ok(Point Set Distribution)") + }) + describe("truncate", () => { + testEval("truncateLeft(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("truncateRight(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("truncate(normal(5,2), 3, 8)", "Ok(Point Set Distribution)") + }) + + describe("exp", () => { + testEval("exp(normal(5,2))", "Ok(Point Set Distribution)") + }) + + describe("pow", () => { + testEval("pow(3, uniform(5,8))", "Ok(Point Set Distribution)") + testEval("pow(uniform(5,8), 3)", "Ok(Point Set Distribution)") + testEval("pow(uniform(5,8), uniform(9, 10))", "Ok(Sample Set Distribution)") + }) + + describe("log", () => { + testEval("log(2, uniform(5,8))", "Ok(Point Set Distribution)") + testEval("log(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("log(normal(5,2), normal(10,1))", "Ok(Sample Set Distribution)") + testEval("log(uniform(5,8))", "Ok(Point Set Distribution)") + testEval("log10(uniform(5,8))", "Ok(Point Set Distribution)") + }) + + describe("dotLog", () => { + testEval("dotLog(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("dotLog(normal(5,2), 3)", "Ok(Point Set Distribution)") + testEval("dotLog(normal(5,2), normal(10,1))", "Ok(Point Set Distribution)") + }) + + describe("dotAdd", () => { + testEval("dotAdd(normal(5,2), lognormal(10,2))", "Ok(Point Set Distribution)") + testEval("dotAdd(normal(5,2), 3)", "Ok(Point Set Distribution)") + }) + + describe("equality", () => { + testEval(~skip=true, "normal(5,2) == normal(5,2)", "Ok(true)") + }) + + describe("mixture", () => { + testEval( + ~skip=true, + "mx(normal(5,2), normal(10,1), normal(15, 1))", + "Ok(Point Set Distribution)", + ) + testEval( + ~skip=true, + "mixture(normal(5,2), normal(10,1), [.2,, .4])", + "Ok(Point Set Distribution)", + ) + }) +}) + +describe("parse on distribution functions", () => { + describe("power", () => { + testParse("normal(5,2) ^ normal(5,1)", "Ok((:pow (:normal 5 2) (:normal 5 1)))") + testParse("3 ^ normal(5,1)", "Ok((:pow 3 (:normal 5 1)))") + testParse("normal(5,2) ^ 3", "Ok((:pow (:normal 5 2) 3))") + }) + describe("pointwise arithmetic expressions", () => { + testParse(~skip=true, "normal(5,2) .+ normal(5,1)", "Ok((:dotAdd (:normal 5 2) (:normal 5 1)))") + testParse(~skip=true, "normal(5,2) .- normal(5,1)", "Ok((:dotSubtract (:normal 5 2) (:normal 5 1)))") + testParse("normal(5,2) .* normal(5,1)", "Ok((:dotMultiply (:normal 5 2) (:normal 5 1)))") + testParse("normal(5,2) ./ normal(5,1)", "Ok((:dotDivide (:normal 5 2) (:normal 5 1)))") + testParse("normal(5,2) .^ normal(5,1)", "Ok((:dotPow (:normal 5 2) (:normal 5 1)))") + }) + describe("equality", () => { + testParse("5 == normal(5,2)", "Ok((:equal 5 (:normal 5 2)))") + }) + describe("pointwise adding two normals", () => { + testParse(~skip=true, "normal(5,2) .+ normal(5,1)", "Ok((:dotAdd (:normal 5 2) (:normal 5 1)))") + }) + describe("exponential of one distribution", () => { + testParse(~skip=true, "exp(normal(5,2)", "Ok((:pow (:normal 5 2) 3))") + }) +}) diff --git a/packages/squiggle-lang/bsconfig.json b/packages/squiggle-lang/bsconfig.json index 64f5ffc1..4af37cb2 100644 --- a/packages/squiggle-lang/bsconfig.json +++ b/packages/squiggle-lang/bsconfig.json @@ -41,7 +41,7 @@ }, "refmt": 3, "warnings": { - "number": "+A-42-48-9-30-4-102" + "number": "+A-42-48-9-30-4-102-20-27-41" }, "ppx-flags": [] } diff --git a/packages/squiggle-lang/src/js/index.ts b/packages/squiggle-lang/src/js/index.ts index cee2987d..7856ef6f 100644 --- a/packages/squiggle-lang/src/js/index.ts +++ b/packages/squiggle-lang/src/js/index.ts @@ -1,7 +1,7 @@ import {runAll} from '../rescript/ProgramEvaluator.gen'; import type { Inputs_SamplingInputs_t as SamplingInputs, exportEnv, exportType, exportDistribution} from '../rescript/ProgramEvaluator.gen'; export type { SamplingInputs, exportEnv, exportDistribution } -export type {t as DistPlus} from '../rescript/pointSetDist/DistPlus.gen'; +export type {t as DistPlus} from '../rescript/OldInterpreter/DistPlus.gen'; export let defaultSamplingInputs : SamplingInputs = { sampleCount : 10000, diff --git a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res similarity index 95% rename from packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.res rename to packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res index 67db34e1..351389ae 100644 --- a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.res +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.res @@ -48,12 +48,24 @@ module OutputLocal = { | _ => None } + let toFloatR = (t: t): result => + switch t { + | Float(r) => Ok(r) + | e => Error(toErrorOrUnreachable(e)) + } + let toString = (t: t) => switch t { | String(d) => Some(d) | _ => None } + let toStringR = (t: t): result => + switch t { + | String(r) => Ok(r) + | e => Error(toErrorOrUnreachable(e)) + } + //This is used to catch errors in other switch statements. let fromResult = (r: result): outputType => switch r { diff --git a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.resi b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi similarity index 88% rename from packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.resi rename to packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi index abbd713e..3c3e132a 100644 --- a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_GenericOperation.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionOperation/DistributionOperation.resi @@ -26,7 +26,9 @@ module Output: { let toDist: t => option let toDistR: t => result let toFloat: t => option + let toFloatR: t => result let toString: t => option + let toStringR: t => result let toError: t => option let fmap: (~env: env, t, GenericDist_Types.Operation.singleParamaterFunction) => t } diff --git a/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res new file mode 100644 index 00000000..a3e249d3 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Distributions/DistributionTypes.res @@ -0,0 +1,92 @@ +type genericDist = + | PointSet(PointSetTypes.pointSetDist) + | SampleSet(array) + | Symbolic(SymbolicDistTypes.symbolicDist) + +type error = + | NotYetImplemented + | Unreachable + | DistributionVerticalShiftIsInvalid + | Other(string) + +module Operation = { + type direction = + | Algebraic + | Pointwise + + type arithmeticOperation = [ + | #Add + | #Multiply + | #Subtract + | #Divide + | #Exponentiate + | #Logarithm + ] + + let arithmeticToFn = (arithmetic: arithmeticOperation) => + switch arithmetic { + | #Add => \"+." + | #Multiply => \"*." + | #Subtract => \"-." + | #Exponentiate => \"**" + | #Divide => \"/." + | #Logarithm => (a, b) => log(a) /. log(b) + } + + type toFloat = [ + | #Cdf(float) + | #Inv(float) + | #Pdf(float) + | #Mean + | #Sample + ] +} + +module DistributionOperation = { + type toDist = + | Normalize + | ToPointSet + | ToSampleSet(int) + | Truncate(option, option) + | Inspect + + type toFloatArray = Sample(int) + + type fromDist = + | ToFloat(Operation.toFloat) + | ToDist(toDist) + | ToDistCombination(Operation.direction, Operation.arithmeticOperation, [#Dist(genericDist) | #Float(float)]) + | ToString + + type singleParamaterFunction = + | FromDist(fromDist) + | FromFloat(fromDist) + + type genericFunctionCallInfo = + | FromDist(fromDist, genericDist) + | FromFloat(fromDist, float) + | Mixture(array<(genericDist, float)>) + + let distCallToString = (distFunction: fromDist): string => + switch distFunction { + | ToFloat(#Cdf(r)) => `cdf(${E.Float.toFixed(r)})` + | ToFloat(#Inv(r)) => `inv(${E.Float.toFixed(r)})` + | ToFloat(#Mean) => `mean` + | ToFloat(#Pdf(r)) => `pdf(${E.Float.toFixed(r)})` + | ToFloat(#Sample) => `sample` + | ToDist(Normalize) => `normalize` + | ToDist(ToPointSet) => `toPointSet` + | ToDist(ToSampleSet(r)) => `toSampleSet(${E.I.toString(r)})` + | ToDist(Truncate(_, _)) => `truncate` + | ToDist(Inspect) => `inspect` + | ToString => `toString` + | ToDistCombination(Algebraic, _, _) => `algebraic` + | ToDistCombination(Pointwise, _, _) => `pointwise` + } + + let toString = (d: genericFunctionCallInfo): string => + switch d { + | FromDist(f, _) | FromFloat(f, _) => distCallToString(f) + | Mixture(_) => `mixture` + } +} diff --git a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res similarity index 99% rename from packages/squiggle-lang/src/rescript/GenericDist/GenericDist.res rename to packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index bb2f8d71..f71d9b93 100644 --- a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -228,7 +228,7 @@ let pointwiseCombinationFloat = ( ): result => { let m = switch arithmeticOperation { | #Add | #Subtract => Error(GenericDist_Types.DistributionVerticalShiftIsInvalid) - | (#Multiply | #Divide | #Exponentiate | #Log) as arithmeticOperation => + | (#Multiply | #Divide | #Exponentiate | #Logarithm) as arithmeticOperation => toPointSetFn(t)->E.R2.fmap(t => { //TODO: Move to PointSet codebase let fn = (secondary, main) => Operation.Scale.toFn(arithmeticOperation, main, secondary) diff --git a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist.resi b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi similarity index 98% rename from packages/squiggle-lang/src/rescript/GenericDist/GenericDist.resi rename to packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi index f567f6be..46db83a7 100644 --- a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi @@ -30,7 +30,7 @@ let truncate: ( ~toPointSetFn: toPointSetFn, ~leftCutoff: option=?, ~rightCutoff: option=?, - unit, + unit ) => result let algebraicCombination: ( diff --git a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_Types.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res similarity index 97% rename from packages/squiggle-lang/src/rescript/GenericDist/GenericDist_Types.res rename to packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res index 98c0da25..43ce5d74 100644 --- a/packages/squiggle-lang/src/rescript/GenericDist/GenericDist_Types.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist_Types.res @@ -20,7 +20,7 @@ module Operation = { | #Subtract | #Divide | #Exponentiate - | #Log + | #Logarithm ] let arithmeticToFn = (arithmetic: arithmeticOperation) => @@ -30,7 +30,7 @@ module Operation = { | #Subtract => \"-." | #Exponentiate => \"**" | #Divide => \"/." - | #Log => (a, b) => log(a) /. log(b) + | #Logarithm => (a, b) => log(a) /. log(b) } type toFloat = [ diff --git a/packages/squiggle-lang/src/rescript/GenericDist/README.md b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/README.md similarity index 100% rename from packages/squiggle-lang/src/rescript/GenericDist/README.md rename to packages/squiggle-lang/src/rescript/Distributions/GenericDist/README.md diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/AlgebraicShapeCombination.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res similarity index 97% rename from packages/squiggle-lang/src/rescript/pointSetDist/AlgebraicShapeCombination.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res index 3c298b18..c0d85e60 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/AlgebraicShapeCombination.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/AlgebraicShapeCombination.res @@ -115,16 +115,17 @@ let combineShapesContinuousContinuous = ( | #Multiply => (m1, m2) => m1 *. m2 | #Divide => (m1, mInv2) => m1 *. mInv2 | #Exponentiate => (m1, mInv2) => m1 ** mInv2 - | #Log => (m1, m2) => log(m1) /. log(m2) + | #Logarithm => (m1, m2) => log(m1) /. log(m2) } // note: here, mInv2 = mean(1 / t2) ~= 1 / mean(t2) - // TODO: I don't know what the variances are for exponentatiation + // TODO: Variances are for exponentatiation or logarithms are almost totally made up and very likely very wrong. // converts the variances and means of the two inputs into the variance of the output let combineVariancesFn = switch op { | #Add => (v1, v2, _, _) => v1 +. v2 | #Subtract => (v1, v2, _, _) => v1 +. v2 | #Multiply => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. | #Exponentiate => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. + | #Logarithm => (v1, v2, m1, m2) => v1 *. v2 +. v1 *. m2 ** 2. +. v2 *. m1 ** 2. | #Divide => (v1, vInv2, m1, mInv2) => v1 *. vInv2 +. v1 *. mInv2 ** 2. +. vInv2 *. m1 ** 2. } @@ -233,7 +234,7 @@ let combineShapesContinuousDiscrete = ( } | #Multiply | #Exponentiate - | #Log + | #Logarithm | #Divide => for j in 0 to t2n - 1 { // creates a new continuous shape for each one of the discrete points, and collects them in outXYShapes. diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/Continuous.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res similarity index 87% rename from packages/squiggle-lang/src/rescript/pointSetDist/Continuous.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res index 92654b35..f01457b7 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/Continuous.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Continuous.res @@ -1,6 +1,47 @@ open Distributions type t = PointSetTypes.continuousShape + +module Analysis = { + let integrate = ( + ~indefiniteIntegralStepwise=(p, h1) => h1 *. p, + ~indefiniteIntegralLinear=(p, a, b) => a *. p +. b *. p ** 2.0 /. 2.0, + t: t, + ): float => { + let xs = t.xyShape.xs + let ys = t.xyShape.ys + + E.A.reducei(xs, 0.0, (acc, _x, i) => { + let areaUnderIntegral = // TODO Take this switch statement out of the loop body + switch (t.interpolation, i) { + | (_, 0) => 0.0 + | (#Stepwise, _) => + indefiniteIntegralStepwise(xs[i], ys[i - 1]) -. + indefiniteIntegralStepwise(xs[i - 1], ys[i - 1]) + | (#Linear, _) => + let x1 = xs[i - 1] + let x2 = xs[i] + if x1 == x2 { + 0.0 + } else { + let h1 = ys[i - 1] + let h2 = ys[i] + let b = (h1 -. h2) /. (x1 -. x2) + let a = h1 -. b *. x1 + indefiniteIntegralLinear(x2, a, b) -. indefiniteIntegralLinear(x1, a, b) + } + } + acc +. areaUnderIntegral + }) + } + + let getMeanOfSquares = (t: t) => { + let indefiniteIntegralLinear = (p, a, b) => a *. p ** 3.0 /. 3.0 +. b *. p ** 4.0 /. 4.0 + let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 3.0 /. 3.0 + integrate(~indefiniteIntegralStepwise, ~indefiniteIntegralLinear, t) + } +} + let getShape = (t: t) => t.xyShape let interpolation = (t: t) => t.interpolation let make = (~interpolation=#Linear, ~integralSumCache=None, ~integralCache=None, xyShape): t => { @@ -194,7 +235,7 @@ module T = Dist({ let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 2.0 /. 2.0 let indefiniteIntegralLinear = (p, a, b) => a *. p ** 2.0 /. 2.0 +. b *. p ** 3.0 /. 3.0 - XYShape.Analysis.integrateContinuousShape( + Analysis.integrate( ~indefiniteIntegralStepwise, ~indefiniteIntegralLinear, t, @@ -204,7 +245,7 @@ module T = Dist({ XYShape.Analysis.getVarianceDangerously( t, mean, - XYShape.Analysis.getMeanOfSquaresContinuousShape, + Analysis.getMeanOfSquares, ) }) diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/Discrete.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res similarity index 98% rename from packages/squiggle-lang/src/rescript/pointSetDist/Discrete.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res index 3e2cc2ce..3b689453 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/Discrete.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res @@ -209,8 +209,9 @@ module T = Dist({ let s = getShape(t) E.A.reducei(s.xs, 0.0, (acc, x, i) => acc +. x *. s.ys[i]) } + let variance = (t: t): float => { - let getMeanOfSquares = t => t |> shapeMap(XYShape.Analysis.squareXYShape) |> mean + let getMeanOfSquares = t => t |> shapeMap(XYShape.T.square) |> mean XYShape.Analysis.getVarianceDangerously(t, mean, getMeanOfSquares) } }) \ No newline at end of file diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/Distributions.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res similarity index 100% rename from packages/squiggle-lang/src/rescript/pointSetDist/Distributions.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res similarity index 98% rename from packages/squiggle-lang/src/rescript/pointSetDist/Mixed.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index cdccdeb2..e05bd408 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -213,8 +213,8 @@ module T = Dist({ let getMeanOfSquares = ({discrete, continuous}: t) => { let discreteMean = - discrete |> Discrete.shapeMap(XYShape.Analysis.squareXYShape) |> Discrete.T.mean - let continuousMean = continuous |> XYShape.Analysis.getMeanOfSquaresContinuousShape + discrete |> Discrete.shapeMap(XYShape.T.square) |> Discrete.T.mean + let continuousMean = continuous |> Continuous.Analysis.getMeanOfSquares (discreteMean *. discreteIntegralSum +. continuousMean *. continuousIntegralSum) /. totalIntegralSum } diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/MixedShapeBuilder.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/MixedShapeBuilder.res similarity index 100% rename from packages/squiggle-lang/src/rescript/pointSetDist/MixedShapeBuilder.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/MixedShapeBuilder.res diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/PointSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res similarity index 100% rename from packages/squiggle-lang/src/rescript/pointSetDist/PointSetDist.res rename to packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetTypes.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetTypes.res new file mode 100644 index 00000000..2d7947c0 --- /dev/null +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetTypes.res @@ -0,0 +1,93 @@ +type domainLimit = { + xPoint: float, + excludingProbabilityMass: float, +} + +type domain = + | Complete + | LeftLimited(domainLimit) + | RightLimited(domainLimit) + | LeftAndRightLimited(domainLimit, domainLimit) + +type distributionType = [ + | #PDF + | #CDF +] + +type xyShape = XYShape.xyShape; +type interpolationStrategy = XYShape.interpolationStrategy; +type extrapolationStrategy = XYShape.extrapolationStrategy; +type interpolator = XYShape.extrapolationStrategy; + +type rec continuousShape = { + xyShape: xyShape, + interpolation: interpolationStrategy, + integralSumCache: option, + integralCache: option, +} + +type discreteShape = { + xyShape: xyShape, + integralSumCache: option, + integralCache: option, +} + +type mixedShape = { + continuous: continuousShape, + discrete: discreteShape, + integralSumCache: option, + integralCache: option, +} + +type pointSetDistMonad<'a, 'b, 'c> = + | Mixed('a) + | Discrete('b) + | Continuous('c) + +@genType +type pointSetDist = pointSetDistMonad + +module ShapeMonad = { + let fmap = (t: pointSetDistMonad<'a, 'b, 'c>, (fn1, fn2, fn3)): pointSetDistMonad<'d, 'e, 'f> => + switch t { + | Mixed(m) => Mixed(fn1(m)) + | Discrete(m) => Discrete(fn2(m)) + | Continuous(m) => Continuous(fn3(m)) + } +} + +type generationSource = + | SquiggleString(string) + | Shape(pointSetDist) + +@genType +type distPlus = { + pointSetDist: pointSetDist, + integralCache: continuousShape, + squiggleString: option, +} + +type mixedPoint = { + continuous: float, + discrete: float, +} + +module MixedPoint = { + type t = mixedPoint + let toContinuousValue = (t: t) => t.continuous + let toDiscreteValue = (t: t) => t.discrete + let makeContinuous = (continuous: float): t => {continuous: continuous, discrete: 0.0} + let makeDiscrete = (discrete: float): t => {continuous: 0.0, discrete: discrete} + + let fmap = (fn: float => float, t: t) => { + continuous: fn(t.continuous), + discrete: fn(t.discrete), + } + + let combine2 = (fn, c: t, d: t): t => { + continuous: fn(c.continuous, d.continuous), + discrete: fn(c.discrete, d.discrete), + } + + let add = combine2((a, b) => a +. b) +} diff --git a/packages/squiggle-lang/src/rescript/sampleSet/Bandwidth.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/Bandwidth.res similarity index 100% rename from packages/squiggle-lang/src/rescript/sampleSet/Bandwidth.res rename to packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/Bandwidth.res diff --git a/packages/squiggle-lang/src/rescript/sampleSet/KdeLibrary.js b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js similarity index 100% rename from packages/squiggle-lang/src/rescript/sampleSet/KdeLibrary.js rename to packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/KdeLibrary.js diff --git a/packages/squiggle-lang/src/rescript/sampleSet/SampleSet.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSet.res similarity index 100% rename from packages/squiggle-lang/src/rescript/sampleSet/SampleSet.res rename to packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSet.res diff --git a/packages/squiggle-lang/src/rescript/symbolicDist/SymbolicDist.res b/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res similarity index 93% rename from packages/squiggle-lang/src/rescript/symbolicDist/SymbolicDist.res rename to packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res index ffeec12f..cd4132b3 100644 --- a/packages/squiggle-lang/src/rescript/symbolicDist/SymbolicDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDist.res @@ -2,7 +2,7 @@ open SymbolicDistTypes module Normal = { type t = normal - let make = (mean: float, stdev: float): result => + let make = (mean: float, stdev: float): result => stdev > 0.0 ? Ok(#Normal({mean: mean, stdev: stdev})) : Error("Standard deviation of normal distribution must be larger than 0") @@ -48,11 +48,13 @@ module Normal = { module Exponential = { type t = exponential - let make = (rate: float): result => + let make = (rate: float): result => rate > 0.0 - ? Ok(#Exponential({ - rate: rate, - })) + ? Ok( + #Exponential({ + rate: rate, + }), + ) : Error("Exponential distributions mean must be larger than 0") let pdf = (x, t: t) => Jstat.Exponential.pdf(x, t.rate) let cdf = (x, t: t) => Jstat.Exponential.cdf(x, t.rate) @@ -89,7 +91,7 @@ module Triangular = { module Beta = { type t = beta - let make = (alpha, beta) => + let make = (alpha, beta) => alpha > 0.0 && beta > 0.0 ? Ok(#Beta({alpha: alpha, beta: beta})) : Error("Beta distribution parameters must be positive") @@ -103,10 +105,10 @@ module Beta = { module Lognormal = { type t = lognormal - let make = (mu, sigma) => - sigma > 0.0 - ? Ok(#Lognormal({mu: mu, sigma: sigma})) - : Error("Lognormal standard deviation must be larger than 0") + let make = (mu, sigma) => + sigma > 0.0 + ? Ok(#Lognormal({mu: mu, sigma: sigma})) + : Error("Lognormal standard deviation must be larger than 0") let pdf = (x, t: t) => Jstat.Lognormal.pdf(x, t.mu, t.sigma) let cdf = (x, t: t) => Jstat.Lognormal.cdf(x, t.mu, t.sigma) let inv = (p, t: t) => Jstat.Lognormal.inv(p, t.mu, t.sigma) @@ -127,8 +129,7 @@ module Lognormal = { let mu = Js.Math.log(mean) -. 0.5 *. Js.Math.log(variance /. meanSquared +. 1.0) let sigma = Js.Math.pow_float(~base=Js.Math.log(variance /. meanSquared +. 1.0), ~exp=0.5) Ok(#Lognormal({mu: mu, sigma: sigma})) - } - else { + } else { Error("Lognormal standard deviation must be larger than 0") } } @@ -154,9 +155,7 @@ module Lognormal = { module Uniform = { type t = uniform let make = (low, high) => - high > low - ? Ok(#Uniform({low: low, high: high})) - : Error("High must be larger than low") + high > low ? Ok(#Uniform({low: low, high: high})) : Error("High must be larger than low") let pdf = (x, t: t) => Jstat.Uniform.pdf(x, t.low, t.high) let cdf = (x, t: t) => Jstat.Uniform.cdf(x, t.low, t.high) @@ -165,7 +164,7 @@ module Uniform = { let mean = (t: t) => Ok(Jstat.Uniform.mean(t.low, t.high)) let toString = ({low, high}: t) => j`Uniform($low,$high)` let truncate = (low, high, t: t): t => { -//todo: add check + //todo: add check let newLow = max(E.O.default(neg_infinity, low), t.low) let newHigh = min(E.O.default(infinity, high), t.high) {low: newLow, high: newHigh} @@ -183,6 +182,15 @@ module Float = { let toString = Js.Float.toString } +module From90thPercentile = { + let make = (low, high) => + switch (low, high) { + | (low, high) if low <= 0.0 && low < high => Ok(Normal.from90PercentCI(low, high)) + | (low, high) if low < high => Ok(Lognormal.from90PercentCI(low, high)) + | (_, _) => Error("Low value must be less than high value.") + } +} + module T = { let minCdfValue = 0.0001 let maxCdfValue = 0.9999 diff --git a/packages/squiggle-lang/src/rescript/symbolicDist/SymbolicDistTypes.res b/packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDistTypes.res similarity index 100% rename from packages/squiggle-lang/src/rescript/symbolicDist/SymbolicDistTypes.res rename to packages/squiggle-lang/src/rescript/Distributions/SymbolicDist/SymbolicDistTypes.res diff --git a/packages/squiggle-lang/src/rescript/interpreter/AST.res b/packages/squiggle-lang/src/rescript/OldInterpreter/AST.res similarity index 100% rename from packages/squiggle-lang/src/rescript/interpreter/AST.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/AST.res diff --git a/packages/squiggle-lang/src/rescript/interpreter/ASTEvaluator.res b/packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res similarity index 100% rename from packages/squiggle-lang/src/rescript/interpreter/ASTEvaluator.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/ASTEvaluator.res diff --git a/packages/squiggle-lang/src/rescript/interpreter/ASTTypes.res b/packages/squiggle-lang/src/rescript/OldInterpreter/ASTTypes.res similarity index 100% rename from packages/squiggle-lang/src/rescript/interpreter/ASTTypes.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/ASTTypes.res diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/DistPlus.res b/packages/squiggle-lang/src/rescript/OldInterpreter/DistPlus.res similarity index 84% rename from packages/squiggle-lang/src/rescript/pointSetDist/DistPlus.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/DistPlus.res index 39f355ab..2b1688b0 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/DistPlus.res +++ b/packages/squiggle-lang/src/rescript/OldInterpreter/DistPlus.res @@ -8,28 +8,22 @@ let make = ( ~pointSetDist, ~squiggleString, - ~domain=Complete, - ~unit=UnspecifiedDistribution, (), ) : t => { let integral = pointSetDistIntegral(pointSetDist); - {pointSetDist, domain, integralCache: integral, unit, squiggleString}; + {pointSetDist, integralCache: integral, squiggleString}; }; let update = ( ~pointSetDist=?, ~integralCache=?, - ~domain=?, - ~unit=?, ~squiggleString=?, t: t, ) => { pointSetDist: E.O.default(t.pointSetDist, pointSetDist), integralCache: E.O.default(t.integralCache, integralCache), - domain: E.O.default(t.domain, domain), - unit: E.O.default(t.unit, unit), squiggleString: E.O.default(t.squiggleString, squiggleString), }; @@ -38,12 +32,6 @@ let updateShape = (pointSetDist, t) => { update(~pointSetDist, ~integralCache, t); }; -let domainIncludedProbabilityMass = (t: t) => - Domain.includedProbabilityMass(t.domain); - -let domainIncludedProbabilityMassAdjustment = (t: t, f) => - f *. Domain.includedProbabilityMass(t.domain); - let toPointSetDist = ({pointSetDist, _}: t) => pointSetDist; let pointSetDistFn = (fn, {pointSetDist}: t) => fn(pointSetDist); @@ -73,8 +61,7 @@ module T = let xToY = (f, t: t) => t |> toPointSetDist - |> PointSetDist.T.xToY(f) - |> MixedPoint.fmap(domainIncludedProbabilityMassAdjustment(t)); + |> PointSetDist.T.xToY(f); let minX = pointSetDistFn(PointSetDist.T.minX); let maxX = pointSetDistFn(PointSetDist.T.maxX); @@ -115,7 +102,6 @@ module T = f, toPointSetDist(t), ) - |> domainIncludedProbabilityMassAdjustment(t); }; // TODO: This part is broken when there is a limit, if this is supposed to be taken into account. diff --git a/packages/squiggle-lang/src/rescript/interpreter/typeSystem/HardcodedFunctions.res b/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res similarity index 99% rename from packages/squiggle-lang/src/rescript/interpreter/typeSystem/HardcodedFunctions.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res index f6741bab..cf8fe470 100644 --- a/packages/squiggle-lang/src/rescript/interpreter/typeSystem/HardcodedFunctions.res +++ b/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/HardcodedFunctions.res @@ -229,6 +229,6 @@ let all = [ ), makeRenderedDistFloat("scaleExp", (dist, float) => verticalScaling(#Exponentiate, dist, float)), makeRenderedDistFloat("scaleMultiply", (dist, float) => verticalScaling(#Multiply, dist, float)), - makeRenderedDistFloat("scaleLog", (dist, float) => verticalScaling(#Log, dist, float)), + makeRenderedDistFloat("scaleLog", (dist, float) => verticalScaling(#Logarithm, dist, float)), Multimodal._function, ] diff --git a/packages/squiggle-lang/src/rescript/interpreter/typeSystem/TypeSystem.res b/packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/TypeSystem.res similarity index 100% rename from packages/squiggle-lang/src/rescript/interpreter/typeSystem/TypeSystem.res rename to packages/squiggle-lang/src/rescript/OldInterpreter/typeSystem/TypeSystem.res diff --git a/packages/squiggle-lang/src/rescript/parser/Parser.res b/packages/squiggle-lang/src/rescript/OldParser/Parser.res similarity index 100% rename from packages/squiggle-lang/src/rescript/parser/Parser.res rename to packages/squiggle-lang/src/rescript/OldParser/Parser.res diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res index 8c94d752..bfb79df1 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExpressionValue.res @@ -12,6 +12,7 @@ type rec expressionValue = | EvSymbol(string) | EvArray(array) | EvRecord(Js.Dict.t) + | EvDistribution(GenericDist_Types.genericDist) type functionCall = (string, array) @@ -35,6 +36,7 @@ let rec toString = aValue => ->Js.String.concatMany("") `{${pairs}}` } + | EvDistribution(dist) => `${GenericDist.toString(dist)}` } let toStringWithType = aValue => @@ -45,6 +47,7 @@ let toStringWithType = aValue => | EvSymbol(_) => `Symbol::${toString(aValue)}` | EvArray(_) => `Array::${toString(aValue)}` | EvRecord(_) => `Record::${toString(aValue)}` + | EvDistribution(_) => `Distribution::${toString(aValue)}` } let argsToString = (args: array): string => { diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res index 4f726650..063fd472 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_ExternalLibrary.res @@ -13,13 +13,10 @@ module Sample = { /* Map external calls of Reducer */ + let dispatch = (call: ExpressionValue.functionCall, chain): result => - switch call { - | ("add", [EvNumber(a), EvNumber(b)]) => Sample.customAdd(a, b)->EvNumber->Ok - - | call => chain(call) - - /* + ReducerInterface_GenericDistribution.dispatch(call) |> E.O.default(chain(call)) +/* If your dispatch is too big you can divide it into smaller dispatches and pass the call so that it gets called finally. The final chain(call) invokes the builtin default functions of the interpreter. @@ -35,4 +32,3 @@ Remember from the users point of view, there are no different modules: // "doSth( constructorType2 )" doSth gets dispatched to the correct module because of the type signature. You get function and operator abstraction for free. You don't need to combine different implementations into one type. That would be duplicating the repsonsibility of the dispatcher. */ - } diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res new file mode 100644 index 00000000..84e0697f --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -0,0 +1,185 @@ +module ExpressionValue = ReducerInterface_ExpressionValue +type expressionValue = ReducerInterface_ExpressionValue.expressionValue + +let runGenericOperation = DistributionOperation.run( + ~env={ + sampleCount: 1000, + xyPointLength: 1000, + }, +) + +module Helpers = { + let arithmeticMap = r => + switch r { + | "add" => #Add + | "dotAdd" => #Add + | "subtract" => #Subtract + | "dotSubtract" => #Subtract + | "divide" => #Divide + | "log" => #Logarithm + | "dotDivide" => #Divide + | "pow" => #Exponentiate + | "dotPow" => #Exponentiate + | "multiply" => #Multiply + | "dotMultiply" => #Multiply + | "dotLog" => #Logarithm + | _ => #Multiply + } + + let catchAndConvertTwoArgsToDists = (args: array): option<( + GenericDist_Types.genericDist, + GenericDist_Types.genericDist, + )> => { + switch args { + | [EvDistribution(a), EvDistribution(b)] => Some((a, b)) + | [EvNumber(a), EvDistribution(b)] => Some((GenericDist.fromFloat(a), b)) + | [EvDistribution(a), EvNumber(b)] => Some((a, GenericDist.fromFloat(b))) + | _ => None + } + } + + let toFloatFn = ( + fnCall: GenericDist_Types.Operation.toFloat, + dist: GenericDist_Types.genericDist, + ) => { + FromDist(GenericDist_Types.Operation.ToFloat(fnCall), dist)->runGenericOperation->Some + } + + let toDistFn = (fnCall: GenericDist_Types.Operation.toDist, dist) => { + FromDist(GenericDist_Types.Operation.ToDist(fnCall), dist)->runGenericOperation->Some + } + + let twoDiststoDistFn = (direction, arithmetic, dist1, dist2) => { + FromDist( + GenericDist_Types.Operation.ToDistCombination( + direction, + arithmeticMap(arithmetic), + #Dist(dist2), + ), + dist1, + )->runGenericOperation + } +} + +module SymbolicConstructors = { + let oneFloat = name => + switch name { + | "exponential" => Ok(SymbolicDist.Exponential.make) + | _ => Error("Unreachable state") + } + + let twoFloat = name => + switch name { + | "normal" => Ok(SymbolicDist.Normal.make) + | "uniform" => Ok(SymbolicDist.Uniform.make) + | "beta" => Ok(SymbolicDist.Beta.make) + | "lognormal" => Ok(SymbolicDist.Lognormal.make) + | "to" => Ok(SymbolicDist.From90thPercentile.make) + | _ => Error("Unreachable state") + } + + let threeFloat = name => + switch name { + | "triangular" => Ok(SymbolicDist.Triangular.make) + | _ => Error("Unreachable state") + } + + let symbolicResultToOutput = ( + symbolicResult: result, + ): option => + switch symbolicResult { + | Ok(r) => Some(Dist(Symbolic(r))) + | Error(r) => Some(GenDistError(Other(r))) + } +} + +module Math = { + let e = 2.718281828459 +} + +let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< + DistributionOperation.outputType, +> => { + let (fnName, args) = call + switch (fnName, args) { + | ("exponential" as fnName, [EvNumber(f1)]) => + SymbolicConstructors.oneFloat(fnName) + ->E.R.bind(r => r(f1)) + ->SymbolicConstructors.symbolicResultToOutput + | ( + ("normal" | "uniform" | "beta" | "lognormal" | "to") as fnName, + [EvNumber(f1), EvNumber(f2)], + ) => + SymbolicConstructors.twoFloat(fnName) + ->E.R.bind(r => r(f1, f2)) + ->SymbolicConstructors.symbolicResultToOutput + | ("triangular" as fnName, [EvNumber(f1), EvNumber(f2), EvNumber(f3)]) => + SymbolicConstructors.threeFloat(fnName) + ->E.R.bind(r => r(f1, f2, f3)) + ->SymbolicConstructors.symbolicResultToOutput + | ("sample", [EvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist) + | ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist) + | ("exp", [EvDistribution(a)]) => + // https://mathjs.org/docs/reference/functions/exp.html + Helpers.twoDiststoDistFn(Algebraic, "pow", GenericDist.fromFloat(Math.e), a)->Some + | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist) + | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist) + | ("cdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist) + | ("pdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist) + | ("inv", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist) + | ("toSampleSet", [EvDistribution(dist), EvNumber(float)]) => + Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist) + | ("truncateLeft", [EvDistribution(dist), EvNumber(float)]) => + Helpers.toDistFn(Truncate(Some(float), None), dist) + | ("truncateRight", [EvDistribution(dist), EvNumber(float)]) => + Helpers.toDistFn(Truncate(None, Some(float)), dist) + | ("truncate", [EvDistribution(dist), EvNumber(float1), EvNumber(float2)]) => + Helpers.toDistFn(Truncate(Some(float1), Some(float2)), dist) + | ("log", [EvDistribution(a)]) => + Helpers.twoDiststoDistFn(Algebraic, "log", a, GenericDist.fromFloat(Math.e))->Some + | ("log10", [EvDistribution(a)]) => + Helpers.twoDiststoDistFn(Algebraic, "log", a, GenericDist.fromFloat(10.0))->Some + | ("unaryMinus", [EvDistribution(a)]) => + Helpers.twoDiststoDistFn(Algebraic, "multiply", a, GenericDist.fromFloat(-1.0))->Some + | (("add" | "multiply" | "subtract" | "divide" | "pow" | "log") as arithmetic, [a, b] as args) => + Helpers.catchAndConvertTwoArgsToDists(args)->E.O2.fmap(((fst, snd)) => + Helpers.twoDiststoDistFn(Algebraic, arithmetic, fst, snd) + ) + | ( + ("dotAdd" + | "dotMultiply" + | "dotSubtract" + | "dotDivide" + | "dotPow" + | "dotLog") as arithmetic, + [a, b] as args, + ) => + Helpers.catchAndConvertTwoArgsToDists(args)->E.O2.fmap(((fst, snd)) => + Helpers.twoDiststoDistFn(Pointwise, arithmetic, fst, snd) + ) + | ("dotLog", [EvDistribution(a)]) => + Helpers.twoDiststoDistFn(Pointwise, "dotLog", a, GenericDist.fromFloat(Math.e))->Some + | ("dotExp", [EvDistribution(a)]) => + Helpers.twoDiststoDistFn(Pointwise, "dotPow", GenericDist.fromFloat(Math.e), a)->Some + | _ => None + } +} + +let genericOutputToReducerValue = (o: DistributionOperation.outputType): result< + expressionValue, + Reducer_ErrorValue.errorValue, +> => + switch o { + | Dist(d) => Ok(ReducerInterface_ExpressionValue.EvDistribution(d)) + | Float(d) => Ok(EvNumber(d)) + | String(d) => Ok(EvString(d)) + | GenDistError(NotYetImplemented) => Error(RETodo("Function not yet implemented")) + | GenDistError(Unreachable) => Error(RETodo("Unreachable")) + | GenDistError(DistributionVerticalShiftIsInvalid) => + Error(RETodo("Distribution Vertical Shift is Invalid")) + | GenDistError(Other(s)) => Error(RETodo(s)) + } + +let dispatch = call => { + dispatchToGenericOutput(call)->E.O2.fmap(genericOutputToReducerValue) +} diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi new file mode 100644 index 00000000..fc7ebabc --- /dev/null +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.resi @@ -0,0 +1,3 @@ +let dispatch: ReducerInterface_ExpressionValue.functionCall => option< + result, +> diff --git a/packages/squiggle-lang/src/rescript/utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res similarity index 99% rename from packages/squiggle-lang/src/rescript/utility/E.res rename to packages/squiggle-lang/src/rescript/Utility/E.res index 636cc600..e36b6124 100644 --- a/packages/squiggle-lang/src/rescript/utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -100,6 +100,7 @@ module O = { module O2 = { let default = (a, b) => O.default(b, a) let toExn = (a, b) => O.toExn(b, a) + let fmap = (a, b) => O.fmap(b, a) } /* Functions */ diff --git a/packages/squiggle-lang/src/rescript/utility/Hash.res b/packages/squiggle-lang/src/rescript/Utility/Hash.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/Hash.res rename to packages/squiggle-lang/src/rescript/Utility/Hash.res diff --git a/packages/squiggle-lang/src/rescript/utility/Jstat.res b/packages/squiggle-lang/src/rescript/Utility/Jstat.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/Jstat.res rename to packages/squiggle-lang/src/rescript/Utility/Jstat.res diff --git a/packages/squiggle-lang/src/rescript/utility/Lodash.res b/packages/squiggle-lang/src/rescript/Utility/Lodash.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/Lodash.res rename to packages/squiggle-lang/src/rescript/Utility/Lodash.res diff --git a/packages/squiggle-lang/src/rescript/utility/Mathjs.res b/packages/squiggle-lang/src/rescript/Utility/Mathjs.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/Mathjs.res rename to packages/squiggle-lang/src/rescript/Utility/Mathjs.res diff --git a/packages/squiggle-lang/src/rescript/utility/MathjsWrapper.js b/packages/squiggle-lang/src/rescript/Utility/MathjsWrapper.js similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/MathjsWrapper.js rename to packages/squiggle-lang/src/rescript/Utility/MathjsWrapper.js diff --git a/packages/squiggle-lang/src/rescript/utility/Operation.res b/packages/squiggle-lang/src/rescript/Utility/Operation.res similarity index 89% rename from packages/squiggle-lang/src/rescript/utility/Operation.res rename to packages/squiggle-lang/src/rescript/Utility/Operation.res index 540bd08c..55e0b42f 100644 --- a/packages/squiggle-lang/src/rescript/utility/Operation.res +++ b/packages/squiggle-lang/src/rescript/Utility/Operation.res @@ -7,11 +7,11 @@ type algebraicOperation = [ | #Subtract | #Divide | #Exponentiate - | #Log + | #Logarithm ] @genType type pointwiseOperation = [#Add | #Multiply | #Exponentiate] -type scaleOperation = [#Multiply | #Exponentiate | #Log | #Divide] +type scaleOperation = [#Multiply | #Exponentiate | #Logarithm | #Divide] type distToFloatOperation = [ | #Pdf(float) | #Cdf(float) @@ -29,7 +29,7 @@ module Algebraic = { | #Multiply => \"*." | #Exponentiate => \"**" | #Divide => \"/." - | #Log => (a, b) => log(a) /. log(b) + | #Logarithm => (a, b) => log(a) /. log(b) } let applyFn = (t, f1, f2) => @@ -45,7 +45,7 @@ module Algebraic = { | #Multiply => "*" | #Exponentiate => "**" | #Divide => "/" - | #Log => "log" + | #Logarithm => "log" } let format = (a, b, c) => b ++ (" " ++ (toString(a) ++ (" " ++ c))) @@ -84,7 +84,7 @@ module Scale = { | #Multiply => \"*." | #Divide => \"/." | #Exponentiate => \"**" - | #Log => (a, b) => log(a) /. log(b) + | #Logarithm => (a, b) => log(a) /. log(b) } let format = (operation: t, value, scaleBy) => @@ -92,7 +92,7 @@ module Scale = { | #Multiply => j`verticalMultiply($value, $scaleBy) ` | #Divide => j`verticalDivide($value, $scaleBy) ` | #Exponentiate => j`verticalExponentiate($value, $scaleBy) ` - | #Log => j`verticalLog($value, $scaleBy) ` + | #Logarithm => j`verticalLog($value, $scaleBy) ` } let toIntegralSumCacheFn = x => @@ -100,7 +100,7 @@ module Scale = { | #Multiply => (a, b) => Some(a *. b) | #Divide => (a, b) => Some(a /. b) | #Exponentiate => (_, _) => None - | #Log => (_, _) => None + | #Logarithm => (_, _) => None } let toIntegralCacheFn = x => @@ -108,7 +108,7 @@ module Scale = { | #Multiply => (_, _) => None // TODO: this could probably just be multiplied out (using Continuous.scaleBy) | #Divide => (_, _) => None | #Exponentiate => (_, _) => None - | #Log => (_, _) => None + | #Logarithm => (_, _) => None } } diff --git a/packages/squiggle-lang/src/rescript/utility/SamplingInputs.res b/packages/squiggle-lang/src/rescript/Utility/SamplingInputs.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/SamplingInputs.res rename to packages/squiggle-lang/src/rescript/Utility/SamplingInputs.res diff --git a/packages/squiggle-lang/src/rescript/utility/Sparklines.res b/packages/squiggle-lang/src/rescript/Utility/Sparklines.res similarity index 100% rename from packages/squiggle-lang/src/rescript/utility/Sparklines.res rename to packages/squiggle-lang/src/rescript/Utility/Sparklines.res diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/XYShape.res b/packages/squiggle-lang/src/rescript/Utility/XYShape.res similarity index 90% rename from packages/squiggle-lang/src/rescript/pointSetDist/XYShape.res rename to packages/squiggle-lang/src/rescript/Utility/XYShape.res index 6cadec60..aba9ec80 100644 --- a/packages/squiggle-lang/src/rescript/pointSetDist/XYShape.res +++ b/packages/squiggle-lang/src/rescript/Utility/XYShape.res @@ -1,4 +1,22 @@ -open PointSetTypes +@genType +type xyShape = { + xs: array, + ys: array, +} + +@genType +type interpolationStrategy = [ + | #Stepwise + | #Linear +] + +@genType +type extrapolationStrategy = [ + | #UseZero + | #UseOutermostPoints +] + +type interpolator = (xyShape, int, float) => float let interpolate = (xMin: float, xMax: float, yMin: float, yMax: float, xIntended: float): float => { let minProportion = (xMax -. xIntended) /. (xMax -. xMin) @@ -25,6 +43,7 @@ module T = { let xTotalRange = (t: t) => maxX(t) -. minX(t) let mapX = (fn, t: t): t => {xs: E.A.fmap(fn, t.xs), ys: t.ys} let mapY = (fn, t: t): t => {xs: t.xs, ys: E.A.fmap(fn, t.ys)} + let square = mapX(x => x ** 2.0) let zip = ({xs, ys}: t) => Belt.Array.zip(xs, ys) let fromArray = ((xs, ys)): t => {xs: xs, ys: ys} let fromArrays = (xs, ys): t => {xs: xs, ys: ys} @@ -126,8 +145,8 @@ module XtoY = { /* Returns a between-points-interpolating function that can be used with PointwiseCombination.combine. Interpolation can either be stepwise (using the value on the left) or linear. Extrapolation can be `UseZero or `UseOutermostPoints. */ let continuousInterpolator = ( - interpolation: PointSetTypes.interpolationStrategy, - extrapolation: PointSetTypes.extrapolationStrategy, + interpolation: interpolationStrategy, + extrapolation: extrapolationStrategy, ): interpolator => switch (interpolation, extrapolation) { | (#Linear, #UseZero) => @@ -392,49 +411,9 @@ let logScorePoint = (sampleCount, t1, t2) => |> E.O.fmap(Pairs.y) module Analysis = { - let integrateContinuousShape = ( - ~indefiniteIntegralStepwise=(p, h1) => h1 *. p, - ~indefiniteIntegralLinear=(p, a, b) => a *. p +. b *. p ** 2.0 /. 2.0, - t: PointSetTypes.continuousShape, - ): float => { - let xs = t.xyShape.xs - let ys = t.xyShape.ys - - E.A.reducei(xs, 0.0, (acc, _x, i) => { - let areaUnderIntegral = // TODO Take this switch statement out of the loop body - switch (t.interpolation, i) { - | (_, 0) => 0.0 - | (#Stepwise, _) => - indefiniteIntegralStepwise(xs[i], ys[i - 1]) -. - indefiniteIntegralStepwise(xs[i - 1], ys[i - 1]) - | (#Linear, _) => - let x1 = xs[i - 1] - let x2 = xs[i] - if x1 == x2 { - 0.0 - } else { - let h1 = ys[i - 1] - let h2 = ys[i] - let b = (h1 -. h2) /. (x1 -. x2) - let a = h1 -. b *. x1 - indefiniteIntegralLinear(x2, a, b) -. indefiniteIntegralLinear(x1, a, b) - } - } - acc +. areaUnderIntegral - }) - } - - let getMeanOfSquaresContinuousShape = (t: PointSetTypes.continuousShape) => { - let indefiniteIntegralLinear = (p, a, b) => a *. p ** 3.0 /. 3.0 +. b *. p ** 4.0 /. 4.0 - let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 3.0 /. 3.0 - integrateContinuousShape(~indefiniteIntegralStepwise, ~indefiniteIntegralLinear, t) - } - let getVarianceDangerously = (t: 't, mean: 't => float, getMeanOfSquares: 't => float): float => { let meanSquared = mean(t) ** 2.0 let meanOfSquares = getMeanOfSquares(t) meanOfSquares -. meanSquared } - - let squareXYShape = T.mapX(x => x ** 2.0) } diff --git a/packages/squiggle-lang/src/rescript/pointSetDist/PointSetTypes.res b/packages/squiggle-lang/src/rescript/pointSetDist/PointSetTypes.res deleted file mode 100644 index ded9c02d..00000000 --- a/packages/squiggle-lang/src/rescript/pointSetDist/PointSetTypes.res +++ /dev/null @@ -1,154 +0,0 @@ -type domainLimit = { - xPoint: float, - excludingProbabilityMass: float, -} - -type domain = - | Complete - | LeftLimited(domainLimit) - | RightLimited(domainLimit) - | LeftAndRightLimited(domainLimit, domainLimit) - -type distributionType = [ - | #PDF - | #CDF -] - -type xyShape = { - xs: array, - ys: array, -} - -type interpolationStrategy = [ - | #Stepwise - | #Linear -] -type extrapolationStrategy = [ - | #UseZero - | #UseOutermostPoints -] - -type interpolator = (xyShape, int, float) => float - -type rec continuousShape = { - xyShape: xyShape, - interpolation: interpolationStrategy, - integralSumCache: option, - integralCache: option, -} - -type discreteShape = { - xyShape: xyShape, - integralSumCache: option, - integralCache: option, -} - -type mixedShape = { - continuous: continuousShape, - discrete: discreteShape, - integralSumCache: option, - integralCache: option, -} - -type pointSetDistMonad<'a, 'b, 'c> = - | Mixed('a) - | Discrete('b) - | Continuous('c) - -@genType -type pointSetDist = pointSetDistMonad - -module ShapeMonad = { - let fmap = (t: pointSetDistMonad<'a, 'b, 'c>, (fn1, fn2, fn3)): pointSetDistMonad<'d, 'e, 'f> => - switch t { - | Mixed(m) => Mixed(fn1(m)) - | Discrete(m) => Discrete(fn2(m)) - | Continuous(m) => Continuous(fn3(m)) - } -} - -type generationSource = - | SquiggleString(string) - | Shape(pointSetDist) - -type distributionUnit = - | UnspecifiedDistribution - -@genType -type distPlus = { - pointSetDist: pointSetDist, - domain: domain, - integralCache: continuousShape, - unit: distributionUnit, - squiggleString: option, -} - -module DistributionUnit = { - let toJson = (distributionUnit: distributionUnit) => - switch distributionUnit { - | _ => Js.Null.fromOption(None) - } -} - -module Domain = { - let excludedProbabilityMass = (t: domain) => - switch t { - | Complete => 0.0 - | LeftLimited({excludingProbabilityMass}) => excludingProbabilityMass - | RightLimited({excludingProbabilityMass}) => excludingProbabilityMass - | LeftAndRightLimited({excludingProbabilityMass: l}, {excludingProbabilityMass: r}) => l +. r - } - - let includedProbabilityMass = (t: domain) => 1.0 -. excludedProbabilityMass(t) - - let initialProbabilityMass = (t: domain) => - switch t { - | Complete - | RightLimited(_) => 0.0 - | LeftLimited({excludingProbabilityMass}) => excludingProbabilityMass - | LeftAndRightLimited({excludingProbabilityMass}, _) => excludingProbabilityMass - } - - let normalizeProbabilityMass = (t: domain) => 1. /. excludedProbabilityMass(t) - - let yPointToSubYPoint = (t: domain, yPoint) => - switch t { - | Complete => Some(yPoint) - | LeftLimited({excludingProbabilityMass}) if yPoint < excludingProbabilityMass => None - | LeftLimited({excludingProbabilityMass}) if yPoint >= excludingProbabilityMass => - Some((yPoint -. excludingProbabilityMass) /. includedProbabilityMass(t)) - | RightLimited({excludingProbabilityMass}) if yPoint > 1. -. excludingProbabilityMass => None - | RightLimited({excludingProbabilityMass}) if yPoint <= 1. -. excludingProbabilityMass => - Some(yPoint /. includedProbabilityMass(t)) - | LeftAndRightLimited({excludingProbabilityMass: l}, _) if yPoint < l => None - | LeftAndRightLimited(_, {excludingProbabilityMass: r}) if yPoint > 1.0 -. r => None - | LeftAndRightLimited({excludingProbabilityMass: l}, _) => - Some((yPoint -. l) /. includedProbabilityMass(t)) - | _ => None - } -} - -type mixedPoint = { - continuous: float, - discrete: float, -} - -module MixedPoint = { - type t = mixedPoint - let toContinuousValue = (t: t) => t.continuous - let toDiscreteValue = (t: t) => t.discrete - let makeContinuous = (continuous: float): t => {continuous: continuous, discrete: 0.0} - let makeDiscrete = (discrete: float): t => {continuous: 0.0, discrete: discrete} - - let fmap = (fn: float => float, t: t) => { - continuous: fn(t.continuous), - discrete: fn(t.discrete), - } - - let combine2 = (fn, c: t, d: t): t => { - continuous: fn(c.continuous, d.continuous), - discrete: fn(c.discrete, d.discrete), - } - - let add = combine2((a, b) => a +. b) -} diff --git a/yarn.lock b/yarn.lock index 067c7e26..9817cdd1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2191,6 +2191,11 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@leichtgewicht/ip-codec@^2.0.1": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.3.tgz#0300943770e04231041a51bd39f0439b5c7ab4f0" + integrity sha512-nkalE/f1RvRGChwBnEIoBfSEYOXnCRdleKuv6+lePbMDrMZXeDQnqak5XDOeBgrPPyPfAdcCu/B5z+v3VhplGg== + "@mdx-js/loader@^1.6.22": version "1.6.22" resolved "https://registry.yarnpkg.com/@mdx-js/loader/-/loader-1.6.22.tgz#d9e8fe7f8185ff13c9c8639c048b123e30d322c4" @@ -2306,9 +2311,9 @@ integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g== "@popperjs/core@^2.5.4", "@popperjs/core@^2.6.0": - version "2.11.4" - resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.4.tgz#d8c7b8db9226d2d7664553a0741ad7d0397ee503" - integrity sha512-q/ytXxO5NKvyT37pmisQAItCFqA7FD/vNb8dgaJy3/630Fsc+Mz9/9f2SziBoIZ30TJooXyTwZmhi1zjXmObYg== + version "2.11.5" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.5.tgz#db5a11bf66bdab39569719555b0f76e138d7bd64" + integrity sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw== "@rollup/plugin-babel@^5.2.0": version "5.3.1" @@ -3590,9 +3595,9 @@ defer-to-connect "^1.0.1" "@testing-library/dom@^8.0.0": - version "8.12.0" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.12.0.tgz#fef5e545533fb084175dda6509ee71d7d2f72e23" - integrity sha512-rBrJk5WjI02X1edtiUcZhgyhgBhiut96r5Jp8J5qktKdcvLcZpKDW8i2hkGMMItxrghjXuQ5AM6aE0imnFawaw== + version "8.13.0" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.13.0.tgz#bc00bdd64c7d8b40841e27a70211399ad3af46f5" + integrity sha512-9VHgfIatKNXQNaZTtLnalIy0jNZzY35a4S3oi08YAt9Hv1VsfZ/DfA45lM8D/UhtHBGJ4/lGwp0PZkVndRkoOQ== dependencies: "@babel/code-frame" "^7.10.4" "@babel/runtime" "^7.12.5" @@ -3604,9 +3609,9 @@ pretty-format "^27.0.2" "@testing-library/jest-dom@^5.16.3": - version "5.16.3" - resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.3.tgz#b76851a909586113c20486f1679ffb4d8ec27bfa" - integrity sha512-u5DfKj4wfSt6akfndfu1eG06jsdyA/IUrlX2n3pyq5UXgXMhXY+NJb8eNK/7pqPWAhCKsCGWDdDO0zKMKAYkEA== + version "5.16.4" + resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd" + integrity sha512-Gy+IoFutbMQcky0k+bqqumXZ1cTGswLsFqmNLzNdSKkU9KGV2u9oXhukCbbJ9/LRPKiqwxEE8VpV/+YZlfkPUA== dependencies: "@babel/runtime" "^7.9.2" "@types/testing-library__jest-dom" "^5.9.1" @@ -4145,7 +4150,7 @@ anymatch "^3.0.0" source-map "^0.6.0" -"@types/ws@^8.2.2": +"@types/ws@^8.5.1": version "8.5.3" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d" integrity sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w== @@ -4172,13 +4177,13 @@ "@types/yargs-parser" "*" "@typescript-eslint/eslint-plugin@^5.5.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.17.0.tgz#704eb4e75039000531255672bf1c85ee85cf1d67" - integrity sha512-qVstvQilEd89HJk3qcbKt/zZrfBZ+9h2ynpAGlWjWiizA7m/MtLT9RoX6gjtpE500vfIg8jogAkDzdCxbsFASQ== + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.18.0.tgz#950df411cec65f90d75d6320a03b2c98f6c3af7d" + integrity sha512-tzrmdGMJI/uii9/V6lurMo4/o+dMTKDH82LkNjhJ3adCW22YQydoRs5MwTiqxGF9CSYxPxQ7EYb4jLNlIs+E+A== dependencies: - "@typescript-eslint/scope-manager" "5.17.0" - "@typescript-eslint/type-utils" "5.17.0" - "@typescript-eslint/utils" "5.17.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/type-utils" "5.18.0" + "@typescript-eslint/utils" "5.18.0" debug "^4.3.2" functional-red-black-tree "^1.0.1" ignore "^5.1.8" @@ -4187,75 +4192,75 @@ tsutils "^3.21.0" "@typescript-eslint/experimental-utils@^5.0.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.17.0.tgz#303ba1d766d715c3225a31845b54941889e52f6c" - integrity sha512-U4sM5z0/ymSYqQT6I7lz8l0ZZ9zrya5VIwrwAP5WOJVabVtVsIpTMxPQe+D3qLyePT+VlETUTO2nA1+PufPx9Q== + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.18.0.tgz#a6b5662e6b0452cb0e75a13662ce3b33cd1be59d" + integrity sha512-hypiw5N0aM2aH91/uMmG7RpyUH3PN/iOhilMwkMFZIbm/Bn/G3ZnbaYdSoAN4PG/XHQjdhBYLi0ZoRZsRYT4hA== dependencies: - "@typescript-eslint/utils" "5.17.0" + "@typescript-eslint/utils" "5.18.0" "@typescript-eslint/parser@^5.5.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.17.0.tgz#7def77d5bcd8458d12d52909118cf3f0a45f89d5" - integrity sha512-aRzW9Jg5Rlj2t2/crzhA2f23SIYFlF9mchGudyP0uiD6SenIxzKoLjwzHbafgHn39dNV/TV7xwQkLfFTZlJ4ig== + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.18.0.tgz#2bcd4ff21df33621df33e942ccb21cb897f004c6" + integrity sha512-+08nYfurBzSSPndngnHvFw/fniWYJ5ymOrn/63oMIbgomVQOvIDhBoJmYZ9lwQOCnQV9xHGvf88ze3jFGUYooQ== dependencies: - "@typescript-eslint/scope-manager" "5.17.0" - "@typescript-eslint/types" "5.17.0" - "@typescript-eslint/typescript-estree" "5.17.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/typescript-estree" "5.18.0" debug "^4.3.2" -"@typescript-eslint/scope-manager@5.17.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.17.0.tgz#4cea7d0e0bc0e79eb60cad431c89120987c3f952" - integrity sha512-062iCYQF/doQ9T2WWfJohQKKN1zmmXVfAcS3xaiialiw8ZUGy05Em6QVNYJGO34/sU1a7a+90U3dUNfqUDHr3w== +"@typescript-eslint/scope-manager@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.18.0.tgz#a7d7b49b973ba8cebf2a3710eefd457ef2fb5505" + integrity sha512-C0CZML6NyRDj+ZbMqh9FnPscg2PrzSaVQg3IpTmpe0NURMVBXlghGZgMYqBw07YW73i0MCqSDqv2SbywnCS8jQ== dependencies: - "@typescript-eslint/types" "5.17.0" - "@typescript-eslint/visitor-keys" "5.17.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" -"@typescript-eslint/type-utils@5.17.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.17.0.tgz#1c4549d68c89877662224aabb29fbbebf5fc9672" - integrity sha512-3hU0RynUIlEuqMJA7dragb0/75gZmwNwFf/QJokWzPehTZousP/MNifVSgjxNcDCkM5HI2K22TjQWUmmHUINSg== +"@typescript-eslint/type-utils@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.18.0.tgz#62dbfc8478abf36ba94a90ddf10be3cc8e471c74" + integrity sha512-vcn9/6J5D6jtHxpEJrgK8FhaM8r6J1/ZiNu70ZUJN554Y3D9t3iovi6u7JF8l/e7FcBIxeuTEidZDR70UuCIfA== dependencies: - "@typescript-eslint/utils" "5.17.0" + "@typescript-eslint/utils" "5.18.0" debug "^4.3.2" tsutils "^3.21.0" -"@typescript-eslint/types@5.17.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.17.0.tgz#861ec9e669ffa2aa9b873dd4d28d9b1ce26d216f" - integrity sha512-AgQ4rWzmCxOZLioFEjlzOI3Ch8giDWx8aUDxyNw9iOeCvD3GEYAB7dxWGQy4T/rPVe8iPmu73jPHuaSqcjKvxw== +"@typescript-eslint/types@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.18.0.tgz#4f0425d85fdb863071680983853c59a62ce9566e" + integrity sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw== -"@typescript-eslint/typescript-estree@5.17.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.17.0.tgz#a7cba7dfc8f9cc2ac78c18584e684507df4f2488" - integrity sha512-X1gtjEcmM7Je+qJRhq7ZAAaNXYhTgqMkR10euC4Si6PIjb+kwEQHSxGazXUQXFyqfEXdkGf6JijUu5R0uceQzg== +"@typescript-eslint/typescript-estree@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.18.0.tgz#6498e5ee69a32e82b6e18689e2f72e4060986474" + integrity sha512-wa+2VAhOPpZs1bVij9e5gyVu60ReMi/KuOx4LKjGx2Y3XTNUDJgQ+5f77D49pHtqef/klglf+mibuHs9TrPxdQ== dependencies: - "@typescript-eslint/types" "5.17.0" - "@typescript-eslint/visitor-keys" "5.17.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/visitor-keys" "5.18.0" debug "^4.3.2" globby "^11.0.4" is-glob "^4.0.3" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/utils@5.17.0", "@typescript-eslint/utils@^5.13.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.17.0.tgz#549a9e1d491c6ccd3624bc3c1b098f5cfb45f306" - integrity sha512-DVvndq1QoxQH+hFv+MUQHrrWZ7gQ5KcJzyjhzcqB1Y2Xes1UQQkTRPUfRpqhS8mhTWsSb2+iyvDW1Lef5DD7vA== +"@typescript-eslint/utils@5.18.0", "@typescript-eslint/utils@^5.13.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.18.0.tgz#27fc84cf95c1a96def0aae31684cb43a37e76855" + integrity sha512-+hFGWUMMri7OFY26TsOlGa+zgjEy1ssEipxpLjtl4wSll8zy85x0GrUSju/FHdKfVorZPYJLkF3I4XPtnCTewA== dependencies: "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.17.0" - "@typescript-eslint/types" "5.17.0" - "@typescript-eslint/typescript-estree" "5.17.0" + "@typescript-eslint/scope-manager" "5.18.0" + "@typescript-eslint/types" "5.18.0" + "@typescript-eslint/typescript-estree" "5.18.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/visitor-keys@5.17.0": - version "5.17.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.17.0.tgz#52daae45c61b0211b4c81b53a71841911e479128" - integrity sha512-6K/zlc4OfCagUu7Am/BD5k8PSWQOgh34Nrv9Rxe2tBzlJ7uOeJ/h7ugCGDCeEZHT6k2CJBhbk9IsbkPI0uvUkA== +"@typescript-eslint/visitor-keys@5.18.0": + version "5.18.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.18.0.tgz#c7c07709823804171d569017f3b031ced7253e60" + integrity sha512-Hf+t+dJsjAKpKSkg3EHvbtEpFFb/1CiOHnvI8bjHgOD4/wAw3gKrA0i94LrbekypiZVanJu3McWJg7rWDMzRTg== dependencies: - "@typescript-eslint/types" "5.17.0" + "@typescript-eslint/types" "5.18.0" eslint-visitor-keys "^3.0.0" "@webassemblyjs/ast@1.11.1": @@ -4717,9 +4722,9 @@ ajv@^8.0.0, ajv@^8.6.0, ajv@^8.8.0: uri-js "^4.2.2" algoliasearch-helper@^3.7.0: - version "3.7.4" - resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.7.4.tgz#3812ea161da52463ec88da52612c9a363c1b181d" - integrity sha512-KmJrsHVm5TmxZ9Oj53XdXuM4CQeu7eVFnB15tpSFt+7is1d1yVCv3hxCLMqYSw/rH42ccv013miQpRr268P8vw== + version "3.8.1" + resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.8.1.tgz#65e1acb7e301309b3c71e587b28a5a6e6619f3fd" + integrity sha512-IGK67xeut0wYRXQw+MlSDYmYK/6e+/a++HVf9MgSWYtPd6QIHWiOKpgMYRJMNF/zMjx0FPA16D/AypgWxSVBnQ== dependencies: "@algolia/events" "^4.0.1" @@ -4961,7 +4966,7 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= -array-flatten@^2.1.0: +array-flatten@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099" integrity sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ== @@ -5575,17 +5580,15 @@ body-parser@1.19.2: raw-body "2.4.3" type-is "~1.6.18" -bonjour@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/bonjour/-/bonjour-3.5.0.tgz#8e890a183d8ee9a2393b3844c691a42bcf7bc9f5" - integrity sha1-jokKGD2O6aI5OzhExpGkK897yfU= +bonjour-service@^1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.0.11.tgz#5418e5c1ac91c89a406f853a942e7892829c0d89" + integrity sha512-drMprzr2rDTCtgEE3VgdA9uUFaUHF+jXduwYSThHJnKMYM+FhI9Z3ph+TX3xy0LtgYHae6CHYPJ/2UnK8nQHcA== dependencies: - array-flatten "^2.1.0" - deep-equal "^1.0.1" + array-flatten "^2.1.2" dns-equal "^1.0.0" - dns-txt "^2.0.2" - multicast-dns "^6.0.1" - multicast-dns-service-types "^1.1.0" + fast-deep-equal "^3.1.3" + multicast-dns "^7.2.4" boolbase@^1.0.0, boolbase@~1.0.0: version "1.0.0" @@ -5752,11 +5755,6 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer-indexof@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c" - integrity sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g== - buffer-xor@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" @@ -7176,18 +7174,6 @@ dedent@^0.7.0: resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw= -deep-equal@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" - integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== - dependencies: - is-arguments "^1.0.4" - is-date-object "^1.0.1" - is-regex "^1.0.4" - object-is "^1.0.1" - object-keys "^1.1.1" - regexp.prototype.flags "^1.2.0" - deep-extend@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" @@ -7408,20 +7394,12 @@ dns-equal@^1.0.0: resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" integrity sha1-s55/HabrCnW6nBcySzR1PEfgZU0= -dns-packet@^1.3.1: - version "1.3.4" - resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-1.3.4.tgz#e3455065824a2507ba886c55a89963bb107dec6f" - integrity sha512-BQ6F4vycLXBvdrJZ6S3gZewt6rcrks9KBgM9vrhW+knGRqc8uEdT7fuCwloc7nny5xNoMJ17HGH0R/6fpo8ECA== +dns-packet@^5.2.2: + version "5.3.1" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.3.1.tgz#eb94413789daec0f0ebe2fcc230bdc9d7c91b43d" + integrity sha512-spBwIj0TK0Ey3666GwIdWVfUpLyubpU53BTCu8iPn4r4oXd9O14Hjg3EHw3ts2oed77/SeckunUYCyRlSngqHw== dependencies: - ip "^1.1.0" - safe-buffer "^5.0.1" - -dns-txt@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/dns-txt/-/dns-txt-2.0.2.tgz#b91d806f5d27188e4ab3e7d107d881a1cc4642b6" - integrity sha1-uR2Ab10nGI5Ks+fRB9iBocxGQrY= - dependencies: - buffer-indexof "^1.0.0" + "@leichtgewicht/ip-codec" "^2.0.1" docsify@^4.12.2: version "4.12.2" @@ -7924,7 +7902,7 @@ eslint-import-resolver-node@^0.3.6: debug "^3.2.7" resolve "^1.20.0" -eslint-module-utils@^2.7.2: +eslint-module-utils@^2.7.3: version "2.7.3" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz#ad7e3a10552fdd0642e1e55292781bd6e34876ee" integrity sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ== @@ -7941,23 +7919,23 @@ eslint-plugin-flowtype@^8.0.3: string-natural-compare "^3.0.1" eslint-plugin-import@^2.25.3: - version "2.25.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz#322f3f916a4e9e991ac7af32032c25ce313209f1" - integrity sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA== + version "2.26.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b" + integrity sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA== dependencies: array-includes "^3.1.4" array.prototype.flat "^1.2.5" debug "^2.6.9" doctrine "^2.1.0" eslint-import-resolver-node "^0.3.6" - eslint-module-utils "^2.7.2" + eslint-module-utils "^2.7.3" has "^1.0.3" - is-core-module "^2.8.0" + is-core-module "^2.8.1" is-glob "^4.0.3" - minimatch "^3.0.4" + minimatch "^3.1.2" object.values "^1.1.5" - resolve "^1.20.0" - tsconfig-paths "^3.12.0" + resolve "^1.22.0" + tsconfig-paths "^3.14.1" eslint-plugin-jest@^25.3.0: version "25.7.0" @@ -8010,9 +7988,9 @@ eslint-plugin-react@^7.27.1: string.prototype.matchall "^4.0.6" eslint-plugin-testing-library@^5.0.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-testing-library/-/eslint-plugin-testing-library-5.2.0.tgz#4e097027345ecc4a2479be12b5a5b9098e7c9c7a" - integrity sha512-fYFH8lA1hbc1Epr9laNm/+YIR2d+R7WI8sFz9jIRAUfqCf21Nb5BzZwhNeZlu9wKXwDtuf+hUM5QJxG1PuDsTQ== + version "5.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-testing-library/-/eslint-plugin-testing-library-5.2.1.tgz#3f89cd28ade81329a11584e0bbea129bede01619" + integrity sha512-88qJv6uzYALtiYJDzhelP3ov0Px/GLgnu+UekjjDxL2nMyvgdTyboKqcDBsvFPmAeizlCoSWOjeBN4DxO0BxaA== dependencies: "@typescript-eslint/utils" "^5.13.0" @@ -8263,7 +8241,7 @@ expect@^27.5.1: jest-matcher-utils "^27.5.1" jest-message-util "^27.5.1" -express@^4.17.1: +express@^4.17.1, express@^4.17.3: version "4.17.3" resolved "https://registry.yarnpkg.com/express/-/express-4.17.3.tgz#f6c7302194a4fb54271b73a1fe7a06478c8f85a1" integrity sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg== @@ -9053,9 +9031,9 @@ got@^9.6.0: url-parse-lax "^3.0.0" graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: - version "4.2.9" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" - integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== gray-matter@^4.0.3: version "4.0.3" @@ -9520,7 +9498,7 @@ http-proxy-agent@^4.0.1: agent-base "6" debug "4" -http-proxy-middleware@^2.0.0: +http-proxy-middleware@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.4.tgz#03af0f4676d172ae775cb5c33f592f40e1a4e07a" integrity sha512-m/4FxX17SUvz4lJ5WPXOHDUuCwIqXLfLHs1s0uZ3oYjhoXlx9csYxaOa0ElDEJ+h8Q4iJ1s+lTMbiCa4EXIJqg== @@ -9738,7 +9716,7 @@ invariant@^2.2.2, invariant@^2.2.4: dependencies: loose-envify "^1.0.0" -ip@^1.1.0, ip@^1.1.5: +ip@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= @@ -9785,7 +9763,7 @@ is-alphanumerical@^1.0.0: is-alphabetical "^1.0.0" is-decimal "^1.0.0" -is-arguments@^1.0.4, is-arguments@^1.1.0: +is-arguments@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== @@ -9849,7 +9827,7 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.2.0, is-core-module@^2.8.0, is-core-module@^2.8.1: +is-core-module@^2.2.0, is-core-module@^2.8.1: version "2.8.1" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211" integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA== @@ -10063,7 +10041,7 @@ is-potential-custom-element-name@^1.0.1: resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== -is-regex@^1.0.4, is-regex@^1.1.2, is-regex@^1.1.4: +is-regex@^1.1.2, is-regex@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== @@ -11755,17 +11733,12 @@ ms@2.1.3, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -multicast-dns-service-types@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz#899f11d9686e5e05cb91b35d5f0e63b773cfc901" - integrity sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE= - -multicast-dns@^6.0.1: - version "6.2.3" - resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-6.2.3.tgz#a0ec7bd9055c4282f790c3c82f4e28db3b31b229" - integrity sha512-ji6J5enbMyGRHIAkAOu3WdV8nggqviKCEKtXcOqfphZZtQrmHKycfynJ2V7eVPUA4NhJ6V7Wf4TmGbTwKE9B6g== +multicast-dns@^7.2.4: + version "7.2.4" + resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-7.2.4.tgz#cf0b115c31e922aeb20b64e6556cbeb34cf0dd19" + integrity sha512-XkCYOU+rr2Ft3LI6w4ye51M3VK31qJXFIxu0XLw169PtKG0Zx47OrXeVW/GCYOfpC9s1yyyf1S+L8/4LY0J9Zw== dependencies: - dns-packet "^1.3.1" + dns-packet "^5.2.2" thunky "^1.0.2" nan@^2.12.1: @@ -12007,14 +11980,6 @@ object-inspect@^1.12.0, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -12697,9 +12662,9 @@ postcss-custom-media@^8.0.0: integrity sha512-FvO2GzMUaTN0t1fBULDeIvxr5IvbDXcIatt6pnJghc736nqNgsGao5NT+5+WVLAQiTt6Cb3YUms0jiPaXhL//g== postcss-custom-properties@^12.1.5: - version "12.1.5" - resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-12.1.5.tgz#e669cfff89b0ea6fc85c45864a32b450cb6b196f" - integrity sha512-FHbbB/hRo/7cxLGkc2NS7cDRIDN1oFqQnUKBiyh4b/gwk8DD8udvmRDpUhEK836kB8ggUCieHVOvZDnF9XhI3g== + version "12.1.6" + resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-12.1.6.tgz#345b5b64c9520bb66390393646e8d5fbb7f10b58" + integrity sha512-QEnQkDkb+J+j2bfJisJJpTAFL+lUFl66rUNvnjPBIvRbZACLG4Eu5bmBCIY4FJCqhwsfbBpmJUyb3FcR/31lAg== dependencies: postcss-value-parser "^4.2.0" @@ -13727,9 +13692,9 @@ rc-menu@~9.3.2: shallowequal "^1.1.0" rc-motion@^2.0.0, rc-motion@^2.0.1, rc-motion@^2.2.0, rc-motion@^2.3.0, rc-motion@^2.3.4, rc-motion@^2.4.3, rc-motion@^2.4.4: - version "2.4.6" - resolved "https://registry.yarnpkg.com/rc-motion/-/rc-motion-2.4.6.tgz#b9e07391927fb7bc14e62dcd839146958db6b2ef" - integrity sha512-nXIHve2EDQZ8BFHfgJI3HYMMOZ7HGsolCfA9ozP99/gc1UqpgKys1TYrQWdXa2trff0V3JLhgn2zz+w9VsyktA== + version "2.4.7" + resolved "https://registry.yarnpkg.com/rc-motion/-/rc-motion-2.4.7.tgz#74f0d9dd16bbeb6cb5a905777ce9d492bb95cb77" + integrity sha512-GmC8dYoxCWrGb2pf0JLok97AGdrOFwaCQIJY1xyhnoOYVZuysU419ITu6OCBcjp3SpeogHK80HA6DIwY1cBblg== dependencies: "@babel/runtime" "^7.11.1" classnames "^2.2.1" @@ -14453,7 +14418,7 @@ regex-parser@^2.2.11: resolved "https://registry.yarnpkg.com/regex-parser/-/regex-parser-2.2.11.tgz#3b37ec9049e19479806e878cabe7c1ca83ccfe58" integrity sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q== -regexp.prototype.flags@^1.2.0, regexp.prototype.flags@^1.4.1: +regexp.prototype.flags@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz#b3f4c0059af9e47eca9f3f660e51d81307e72307" integrity sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ== @@ -14989,7 +14954,7 @@ select-hose@^2.0.0: resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo= -selfsigned@^2.0.0: +selfsigned@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.0.1.tgz#8b2df7fa56bf014d19b6007655fff209c0ef0a56" integrity sha512-LmME957M1zOsUhG+67rAjKfiWFox3SBxE/yymatMZsAx+oMrJ0YQ8AToOnyCm7xbeg2ep37IHLxdu0o2MavQOQ== @@ -15696,7 +15661,7 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" -strip-ansi@^7.0.0, strip-ansi@^7.0.1: +strip-ansi@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== @@ -16262,7 +16227,7 @@ tsconfig-paths-webpack-plugin@^3.5.2: enhanced-resolve "^5.7.0" tsconfig-paths "^3.9.0" -tsconfig-paths@^3.12.0, tsconfig-paths@^3.9.0: +tsconfig-paths@^3.14.1, tsconfig-paths@^3.9.0: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" integrity sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ== @@ -17321,38 +17286,37 @@ webpack-dev-middleware@^5.3.1: schema-utils "^4.0.0" webpack-dev-server@^4.6.0, webpack-dev-server@^4.7.4: - version "4.7.4" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.7.4.tgz#d0ef7da78224578384e795ac228d8efb63d5f945" - integrity sha512-nfdsb02Zi2qzkNmgtZjkrMOcXnYZ6FLKcQwpxT7MvmHKc+oTtDsBju8j+NMyAygZ9GW1jMEUpy3itHtqgEhe1A== + version "4.8.0" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.8.0.tgz#022bb845946e31ca01527509a942869ecfc7e047" + integrity sha512-yZ7OWVP1nOtv8s10R/ZCsH6zf6QKkNusMRBE9DsQbOknRzKaFYYrbwVPCXp8ynUOTt3RlD9szM8H0pUlrJ6wcw== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" "@types/express" "^4.17.13" "@types/serve-index" "^1.9.1" "@types/sockjs" "^0.3.33" - "@types/ws" "^8.2.2" + "@types/ws" "^8.5.1" ansi-html-community "^0.0.8" - bonjour "^3.5.0" + bonjour-service "^1.0.11" chokidar "^3.5.3" colorette "^2.0.10" compression "^1.7.4" connect-history-api-fallback "^1.6.0" default-gateway "^6.0.3" - del "^6.0.0" - express "^4.17.1" + express "^4.17.3" graceful-fs "^4.2.6" html-entities "^2.3.2" - http-proxy-middleware "^2.0.0" + http-proxy-middleware "^2.0.3" ipaddr.js "^2.0.1" open "^8.0.9" p-retry "^4.5.0" portfinder "^1.0.28" + rimraf "^3.0.2" schema-utils "^4.0.0" - selfsigned "^2.0.0" + selfsigned "^2.0.1" serve-index "^1.9.1" sockjs "^0.3.21" spdy "^4.0.2" - strip-ansi "^7.0.0" webpack-dev-middleware "^5.3.1" ws "^8.4.2"