From eb5f5245b66381c6ce5a21d1a84cf95d10d951a3 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Tue, 15 Feb 2022 15:58:43 -0500 Subject: [PATCH] ExpressionTree -> AST --- .../__tests__/Distributions__Test.res | 4 +-- .../__tests__/Hardcoded__Test.res | 4 +-- packages/squiggle-lang/dist/index.js | 20 +++++------ packages/squiggle-lang/dist/report.html | 2 +- .../src/rescript/ProgramEvaluator.res | 36 +++++++++---------- .../{ExpressionTree.res => AST.res} | 8 ++--- .../{ExpressionTreeBasic.res => ASTBasic.res} | 2 +- ...sionTreeEvaluator.res => ASTEvaluator.res} | 14 ++++---- .../{ExpressionTypes.res => ASTTypes.res} | 8 ++--- .../src/rescript/interpreter/Operation.res | 4 +-- .../src/rescript/interpreter/PTypes.res | 10 +++--- .../typeSystem/HardcodedFunctions.res | 4 +-- .../interpreter/typeSystem/TypeSystem.res | 14 ++++---- .../parser/{MathJsParser.res => Parser.res} | 22 ++++++------ .../pointSet/AlgebraicShapeCombination.res | 4 +-- .../src/rescript/pointSet/Continuous.res | 4 +-- .../src/rescript/pointSet/Discrete.res | 2 +- .../src/rescript/pointSet/Mixed.res | 2 +- .../src/rescript/pointSet/Shape.res | 4 +-- .../src/rescript/sampleSet/SamplesToShape.res | 2 +- .../rescript/symbolicDist/SymbolicDist.res | 4 +-- 21 files changed, 87 insertions(+), 87 deletions(-) rename packages/squiggle-lang/src/rescript/interpreter/{ExpressionTree.res => AST.res} (73%) rename packages/squiggle-lang/src/rescript/interpreter/{ExpressionTreeBasic.res => ASTBasic.res} (96%) rename packages/squiggle-lang/src/rescript/interpreter/{ExpressionTreeEvaluator.res => ASTEvaluator.res} (95%) rename packages/squiggle-lang/src/rescript/interpreter/{ExpressionTypes.res => ASTTypes.res} (96%) rename packages/squiggle-lang/src/rescript/parser/{MathJsParser.res => Parser.res} (93%) diff --git a/packages/squiggle-lang/__tests__/Distributions__Test.res b/packages/squiggle-lang/__tests__/Distributions__Test.res index 76a3fe6a..650b4446 100644 --- a/packages/squiggle-lang/__tests__/Distributions__Test.res +++ b/packages/squiggle-lang/__tests__/Distributions__Test.res @@ -383,9 +383,9 @@ let shape: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]} // let numSamples = 10000; // open Distributions.Shape; // let normal: SymbolicDistTypes.symbolicDist = `Normal({mean, stdev}); -// let normalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(normal)); +// let normalShape = AST.toShape(numSamples, `SymbolicDist(normal)); // let lognormal = SymbolicDist.Lognormal.fromMeanAndStdev(mean, stdev); -// let lognormalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(lognormal)); +// let lognormalShape = AST.toShape(numSamples, `SymbolicDist(lognormal)); // makeTestCloseEquality( // "Mean of a normal", diff --git a/packages/squiggle-lang/__tests__/Hardcoded__Test.res b/packages/squiggle-lang/__tests__/Hardcoded__Test.res index e1346ba3..029b448d 100644 --- a/packages/squiggle-lang/__tests__/Hardcoded__Test.res +++ b/packages/squiggle-lang/__tests__/Hardcoded__Test.res @@ -10,7 +10,7 @@ let makeTest = (~only=false, str, item1, item2) => expect(item1) |> toEqual(item2) ); -let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = { +let evalParams: ASTTypes.AST.evaluationParams = { samplingInputs: { sampleCount: 1000, outputXYPoints: 10000, @@ -25,7 +25,7 @@ let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = { ("T", `SymbolicDist(`Float(1000000000000.0))), |] ->Belt.Map.String.fromArray, - evaluateNode: ExpressionTreeEvaluator.toLeaf, + evaluateNode: ASTEvaluator.toLeaf, }; let shape1: PointSetTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]}; diff --git a/packages/squiggle-lang/dist/index.js b/packages/squiggle-lang/dist/index.js index f1be24b8..7266c515 100644 --- a/packages/squiggle-lang/dist/index.js +++ b/packages/squiggle-lang/dist/index.js @@ -1346,22 +1346,22 @@ var i=require("pdfast"),e=require("lodash"),t=function(t,n,r){var u=arguments.le },{"rescript/lib/js/caml.js":"gGFE","rescript/lib/js/array.js":"d4B1","rescript/lib/js/curry.js":"NSLD","jstat":"l9TD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_array.js":"Tpli","./KdeLibrary.js":"iO5H","../utility/E.bs.js":"xX5m","../distribution/XYShape.bs.js":"Lf2V","../distribution/Discrete.bs.js":"Ms6F","./Bandwidth.bs.js":"Oh6H","../distribution/Continuous.bs.js":"CVcq","../distribution/MixedShapeBuilder.bs.js":"O6rr"}],"OH0m":[function(require,module,exports) { "use strict";function e(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var t=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/belt_MapString.js"),o=require("../utility/E.bs.js");function u(e,r){return t._2(o.O.fmap,function(e){return e[1]},t._2(o.A.getBy,e,function(e){return e[0]===r}))}function i(e,r){return o.O.toResult(r+" expected and not found",u(e,r))}function a(e,r){return t._2(o.A.fmap,function(r){return[r,u(e,r)]},r)}var f={getByName:u,getByNameResult:i,getByNames:a};function s(e){if("object"===r(e)){var t=e.NAME;if("SymbolicDist"===t){var n=e.VAL;return"object"===r(n)&&"Float"===n.NAME?n.VAL:void 0}if("RenderedDist"===t){var o=e.VAL;switch(0|o.TAG){case 1:var u=o._0.xyShape,i=u.xs;if(1!==i.length)return;var a=i[0],f=u.ys;if(1!==f.length)return;return 1!==f[0]?void 0:a;case 0:case 2:return}}}}function d(e){var r=s(e);return void 0!==r?{NAME:"SymbolicDist",VAL:{NAME:"Float",VAL:r}}:e}function c(e){return{sampleCount:t._2(o.O.$$default,1e4,e.sampleCount),outputXYPoints:t._2(o.O.$$default,1e4,e.outputXYPoints),kernelWidth:e.kernelWidth,shapeLength:t._2(o.O.$$default,1e4,e.shapeLength)}}var l={withDefaults:c},A=n.fromArray([]);function m(e,r){return n.merge(e,r,function(e,r,t){return void 0!==t?t:void 0!==r?r:void 0})}var y=n.update,v=n.get;function b(t,o){var u=n.get(t,o);if(void 0!==u&&"object"===r(u)&&"Function"===u.NAME){var i=u.VAL;return e({TAG:0,_0:[i[0],i[1]]},Symbol.for("name"),"Ok")}return e({TAG:1,_0:"Function "+o+" not found"},Symbol.for("name"),"Error")}var p={MS:void 0,fromArray:n.fromArray,empty:A,mergeKeepSecond:m,update:y,get:v,getFunction:b};function _(e){return t._1(e.evaluateNode,e)}function S(e,r,n){var u=t._2(e.evaluateNode,e,n);return t._2(o.R.bind,u,t._1(r,e))}function g(e,r){return t._2(e.evaluateNode,e,{NAME:"Render",VAL:r})}function N(t,n){if("object"===r(n)&&"RenderedDist"===n.NAME)return e({TAG:0,_0:n},Symbol.for("name"),"Ok");var o=g(t,n);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var u=o._0;return"object"===r(u)&&"RenderedDist"===u.NAME?e({TAG:0,_0:{NAME:"RenderedDist",VAL:u.VAL}},Symbol.for("name"),"Ok"):e({TAG:1,_0:"Did not render as requested"},Symbol.for("name"),"Error")}function E(t,n){var o=N(t,n);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var u=o._0;return"object"===r(u)&&"RenderedDist"===u.NAME?e({TAG:0,_0:u.VAL},Symbol.for("name"),"Ok"):e({TAG:1,_0:"Did not render as requested"},Symbol.for("name"),"Error")}function h(e){if("object"===r(e)&&"RenderedDist"===e.NAME)return e.VAL}function L(e){switch(0|e.TAG){case 1:var r=e._0.xyShape,t=r.xs;if(1!==t.length)return;var n=t[0],o=r.ys;if(1!==o.length)return;return 1!==o[0]?void 0:{NAME:"SymbolicDist",VAL:{NAME:"Float",VAL:n}};case 0:case 2:return}}function M(e){var r=h(e);return o.O.toResult("Not valid shape",t._2(o.O.bind,r,L))}var R={render:g,ensureIsRendered:N,ensureIsRenderedAndGetShape:E,getShape:h,_toFloat:L,toFloat:M},G={Hash:f,getFloat:s,toFloatIfNeeded:d,SamplingInputs:l,Environment:p,evaluateNode:_,evaluateAndRetry:S,Render:R},T={};exports.ExpressionTree=G,exports.Program=T; },{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_MapString.js":"mO07","../utility/E.bs.js":"xX5m"}],"uF38":[function(require,module,exports) { -"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/belt_Array.js"),i=require("rescript/lib/js/caml_option.js"),o=require("../utility/E.bs.js"),u=require("../distribution/Shape.bs.js"),s=require("./Operation.bs.js"),m=require("../symbolic/SymbolicDist.bs.js"),a=require("../samplesRenderer/SamplesToShape.bs.js"),f=require("./ExpressionTypes.bs.js");function l(e){if("object"===r(e)&&"Function"===e.NAME)return e.VAL}function c(e){return e[0]}function p(e){return e[1]}function b(r,i,u){if(o.A.length(i)!==o.A.length(c(u)))return e({TAG:1,_0:"Wrong number of variables"},Symbol.for("name"),"Error");var s=n._1(f.ExpressionTree.Environment.fromArray,t.zip(c(u),i)),m={samplingInputs:r.samplingInputs,environment:n._2(f.ExpressionTree.Environment.mergeKeepSecond,r.environment,s),evaluateNode:r.evaluateNode};return n._2(r.evaluateNode,m,p(u))}var d={fromNode:l,argumentNames:c,internals:p,run:b};function y(e){if("object"!==r(e))return!1;var n=e.NAME;return"RenderedDist"===n||"Function"===n||"SymbolicDist"===n}function A(e){if("object"===r(e)){var n=e.NAME;return"RenderedDist"===n||"Function"===n||"SymbolicDist"===n?e:void 0}}var v={isPrimative:y,fromNode:A};function S(e){if("object"!==r(e))return!1;var n=e.NAME;return"RenderedDist"===n||"SymbolicDist"===n}function N(n){if("object"!==r(n))return e({TAG:1,_0:"Not valid type"},Symbol.for("name"),"Error");var t=n.NAME;return"SymbolicDist"===t?e({TAG:0,_0:{NAME:"SymbolicDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):"RenderedDist"===t?e({TAG:0,_0:{NAME:"RenderedDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):e({TAG:1,_0:"Not valid type"},Symbol.for("name"),"Error")}function _(r,t){if(S(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=n._2(f.ExpressionTree.Render.render,r,t);return 0===i.TAG?e({TAG:0,_0:i._0},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function E(e,t,o){if("object"===r(o)){var u=o.NAME;return"SymbolicDist"===u?i.some(n._1(t,o.VAL)):"RenderedDist"===u?i.some(n._1(e,o.VAL)):void 0}}function j(e){return function(r){return E(function(r){return u.sampleNRendered(e,r)},function(r){return m.T.sampleN(e,r)},r)}}function g(e,r,i,u){var m=j(e)(i),a=j(e)(u);if(void 0!==m&&void 0!==a)return n._2(o.A.fmap,function(e){return s.Algebraic.toFn(r)(e[0],e[1])},t.zip(m,a))}function D(e,r,t,i){var u=_(e,t),s=_(e,i),m=o.R.merge(u,s);return n._2(o.R.bind,m,function(t){var i=g(e.samplingInputs.sampleCount,r,t[0],t[1]),u=e.samplingInputs,s=n._2(o.O.fmap,function(e){return a.fromSamples(u,e)},i),m=o.O.toResult("No response",n._2(o.O.bind,s,function(e){return e.shape}));return n._2(o.R.fmap,function(e){return{NAME:"Normalize",VAL:{NAME:"RenderedDist",VAL:e}}},m)})}var T={isSamplingDistribution:S,fromNode:N,renderIfIsNotSamplingDistribution:_,map:E,sampleN:j,getCombinationSamples:g,combineShapesUsingSampling:D};exports.$$Function=d,exports.Primative=v,exports.SamplingDistribution=T; -},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./Operation.bs.js":"S4ET","../symbolic/SymbolicDist.bs.js":"wl7Z","../samplesRenderer/SamplesToShape.bs.js":"wVv4","./ExpressionTypes.bs.js":"OH0m"}],"N3i9":[function(require,module,exports) { +"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/curry.js"),t=require("rescript/lib/js/belt_Array.js"),i=require("rescript/lib/js/caml_option.js"),o=require("../utility/E.bs.js"),u=require("../distribution/Shape.bs.js"),s=require("./Operation.bs.js"),m=require("../symbolic/SymbolicDist.bs.js"),a=require("../samplesRenderer/SamplesToShape.bs.js"),f=require("./ASTTypes.bs.js");function l(e){if("object"===r(e)&&"Function"===e.NAME)return e.VAL}function c(e){return e[0]}function p(e){return e[1]}function b(r,i,u){if(o.A.length(i)!==o.A.length(c(u)))return e({TAG:1,_0:"Wrong number of variables"},Symbol.for("name"),"Error");var s=n._1(f.ExpressionTree.Environment.fromArray,t.zip(c(u),i)),m={samplingInputs:r.samplingInputs,environment:n._2(f.ExpressionTree.Environment.mergeKeepSecond,r.environment,s),evaluateNode:r.evaluateNode};return n._2(r.evaluateNode,m,p(u))}var d={fromNode:l,argumentNames:c,internals:p,run:b};function y(e){if("object"!==r(e))return!1;var n=e.NAME;return"RenderedDist"===n||"Function"===n||"SymbolicDist"===n}function A(e){if("object"===r(e)){var n=e.NAME;return"RenderedDist"===n||"Function"===n||"SymbolicDist"===n?e:void 0}}var v={isPrimative:y,fromNode:A};function S(e){if("object"!==r(e))return!1;var n=e.NAME;return"RenderedDist"===n||"SymbolicDist"===n}function N(n){if("object"!==r(n))return e({TAG:1,_0:"Not valid type"},Symbol.for("name"),"Error");var t=n.NAME;return"SymbolicDist"===t?e({TAG:0,_0:{NAME:"SymbolicDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):"RenderedDist"===t?e({TAG:0,_0:{NAME:"RenderedDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):e({TAG:1,_0:"Not valid type"},Symbol.for("name"),"Error")}function _(r,t){if(S(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=n._2(f.ExpressionTree.Render.render,r,t);return 0===i.TAG?e({TAG:0,_0:i._0},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function E(e,t,o){if("object"===r(o)){var u=o.NAME;return"SymbolicDist"===u?i.some(n._1(t,o.VAL)):"RenderedDist"===u?i.some(n._1(e,o.VAL)):void 0}}function j(e){return function(r){return E(function(r){return u.sampleNRendered(e,r)},function(r){return m.T.sampleN(e,r)},r)}}function g(e,r,i,u){var m=j(e)(i),a=j(e)(u);if(void 0!==m&&void 0!==a)return n._2(o.A.fmap,function(e){return s.Algebraic.toFn(r)(e[0],e[1])},t.zip(m,a))}function D(e,r,t,i){var u=_(e,t),s=_(e,i),m=o.R.merge(u,s);return n._2(o.R.bind,m,function(t){var i=g(e.samplingInputs.sampleCount,r,t[0],t[1]),u=e.samplingInputs,s=n._2(o.O.fmap,function(e){return a.fromSamples(u,e)},i),m=o.O.toResult("No response",n._2(o.O.bind,s,function(e){return e.shape}));return n._2(o.R.fmap,function(e){return{NAME:"Normalize",VAL:{NAME:"RenderedDist",VAL:e}}},m)})}var T={isSamplingDistribution:S,fromNode:N,renderIfIsNotSamplingDistribution:_,map:E,sampleN:j,getCombinationSamples:g,combineShapesUsingSampling:D};exports.$$Function=d,exports.Primative=v,exports.SamplingDistribution=T; +},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_option.js":"dzFO","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./Operation.bs.js":"S4ET","../symbolic/SymbolicDist.bs.js":"wl7Z","../samplesRenderer/SamplesToShape.bs.js":"wVv4","./ASTTypes.bs.js":"OH0m"}],"N3i9":[function(require,module,exports) { "use strict";var r=function(r,p){var l,t;t=p.length;var e=[];for(l=0;l1e4?"Sampling":"Analytical"}function y(r,e,i,u){var a=o.R.merge(t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,i),t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,u));return n._2(o.R.bind,a,function(n){var o=n[1],i=n[0];return"Sampling"===d(i,o)?t.SamplingDistribution.combineShapesUsingSampling(r,e,i,o):b(r,e,i,o)})}function p(i,t,u,a){var s=m(t,u,a);return n._2(o.R.bind,s,function(n){return"object"===e(n)&&"SymbolicDist"===n.NAME?r({TAG:0,_0:n},Symbol.for("name"),"Ok"):y(i,t,u,a)})}var E={tryAnalyticalSimplification:m,combinationByRendering:b,nodeScore:l,choose:d,combine:y,operationToLeaf:p};function S(o,t,u){var s=n._2(f.ExpressionTree.Render.render,o,t),A=n._2(f.ExpressionTree.Render.render,o,u);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(function(r,e){return r+e},function(r,e){return a.combinePointwise(void 0,void 0,"CDF",function(r,e){return r+e},r,e)},function(r,e){return r+e},c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function _(o,t,u,a){var s=n._2(f.ExpressionTree.Render.render,t,u),A=n._2(f.ExpressionTree.Render.render,t,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(void 0,void 0,o,c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function T(r,e,n,o){return"Add"===e?S(r,n,o):_("Exponentiate"===e?function(r,e){return Math.pow(r,e)}:function(r,e){return r*e},r,n,o)}var v={pointwiseAdd:S,pointwiseCombine:_,operationToLeaf:T};function L(r,n,o){if(void 0!==r){if(void 0!==n&&r>n)return{NAME:"Error",VAL:"Left truncation bound must be smaller than right truncation bound."}}else if(void 0===n)return{NAME:"Solution",VAL:o};if("object"!==e(o))return"NoSolution";if("SymbolicDist"!==o.NAME)return"NoSolution";var i=o.VAL;return"object"===e(i)&&"Uniform"===i.NAME?{NAME:"Solution",VAL:{NAME:"SymbolicDist",VAL:{NAME:"Uniform",VAL:A.Uniform.truncate(r,n,i.VAL)}}}:"NoSolution"}function R(o,t,u,a){var s=n._2(f.ExpressionTree.Render.ensureIsRendered,o,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var A=s._0;return"object"===e(A)&&"RenderedDist"===A.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._3(i.T.truncate,t,u,A.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Could not truncate distribution."},Symbol.for("name"),"Error")}function V(n,o,i,t){var u=L(o,i,t);return"object"===e(u)?"Error"===u.NAME?r({TAG:1,_0:u.VAL},Symbol.for("name"),"Error"):r({TAG:0,_0:u.VAL},Symbol.for("name"),"Ok"):R(n,o,i,t)}var N={trySimplification:L,truncateAsShape:R,operationToLeaf:V};function G(o,t){if("object"!==e(t))return f.ExpressionTree.evaluateAndRetry(o,G,t);var u=t.NAME;return"SymbolicDist"===u?r({TAG:0,_0:t},Symbol.for("name"),"Ok"):"RenderedDist"===u?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._1(i.T.normalize,t.VAL)}},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(o,G,t)}var M={operationToLeaf:G};function D(r,e,o){return n._4(s.$$Function.Ts.findByNameAndRun,c.all,r,e,o)}function g(r,e,i){var u=n._2(f.ExpressionTree.Environment.getFunction,e.environment,r);return n._2(o.R.bind,u,function(r){return t.$$Function.run(e,i,[r[0],r[1]])})}function j(r,e,i){return n._2(o.O.$$default,g(e,r,i),D(e,r,i))}function x(r,e,i){var t=n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(e){return n._2(r.evaluateNode,r,e)},i));return n._2(o.R.bind,t,function(n){return j(r,e,n)})}var O={_runHardcodedFunction:D,_runLocalFunction:g,_runWithEvaluatedInputs:j,run:x};function h(n,o){if("object"!==e(o))return f.ExpressionTree.evaluateAndRetry(n,h,o);var i=o.NAME;return"SymbolicDist"===i?r({TAG:0,_0:{NAME:"RenderedDist",VAL:A.T.toShape(n.samplingInputs.shapeLength,o.VAL)}},Symbol.for("name"),"Ok"):"Function"===i?r({TAG:1,_0:"Cannot render a function"},Symbol.for("name"),"Error"):"RenderedDist"===i?r({TAG:0,_0:o},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(n,h,o)}var w={operationToLeaf:h};function k(e,i){var t=i.NAME;if("RenderedDist"===t||"Function"===t||"SymbolicDist"===t)return r({TAG:0,_0:i},Symbol.for("name"),"Ok");if("FunctionCall"===t){var u=i.VAL,a=x(e,u[0],u[1]);return n._2(o.R.bind,a,function(r){return k(e,r)})}if("AlgebraicCombination"===t){var s=i.VAL;return p(e,s[0],s[1],s[2])}if("PointwiseCombination"===t){var A=i.VAL;return T(e,A[0],A[1],A[2])}if("Symbol"===t){var c=i.VAL,m=o.O.toResult("Undeclared variable "+c,n._2(f.ExpressionTree.Environment.get,e.environment,c));return n._2(o.R.bind,m,function(r){return k(e,r)})}if("Truncate"!==t)return"Hash"===t?n._2(o.R.fmap,function(r){return{NAME:"Hash",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){var i=r[0];return n._2(o.R.fmap,function(r){return[i,r]},k(e,r[1]))},i.VAL))):"Array"===t?n._2(o.R.fmap,function(r){return{NAME:"Array",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){return k(e,r)},i.VAL))):"Render"===t?h(e,i.VAL):G(e,i.VAL);var b=i.VAL;return V(e,b[0],b[1],b[2])}exports.AlgebraicCombination=E,exports.PointwiseCombination=v,exports.Truncate=N,exports.Normalize=M,exports.FunctionCall=O,exports.Render=w,exports.toLeaf=k; -},{"rescript/lib/js/curry.js":"NSLD","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./PTypes.bs.js":"uF38","../distribution/XYShape.bs.js":"Lf2V","../distribution/Continuous.bs.js":"CVcq","../typeSystem/TypeSystem.bs.js":"TKgk","../symbolic/SymbolicDist.bs.js":"wl7Z","./ExpressionTypes.bs.js":"OH0m","../typeSystem/HardcodedFunctions.bs.js":"BBdU"}],"H74a":[function(require,module,exports) { +"use strict";function r(r,e,o){return e in r?Object.defineProperty(r,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[e]=o,r}function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var o=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/belt_Array.js"),t=require("rescript/lib/js/caml_splice_call.js"),i=require("../utility/E.bs.js"),a=require("../expressionTree/PTypes.bs.js"),u=require("../expressionTree/ASTTypes.bs.js"),f=require("../expressionTree/ExpressionTreeBasic.bs.js"),A=u.ExpressionTree.getFloat;function m(r){var e=r.NAME;return"Float"===e?"Float: "+r.VAL.toString():"RenderedDist"===e?"[rendered Shape]":"Hash"===e?"{"+t.spliceObjApply(",","concat",[o._2(i.A.fmap,function(r){return r[0]+":"+m(r[1])},r.VAL)])+"}":"Array"===e?"["+t.spliceObjApply(",","concat",[o._2(i.A.fmap,m,r.VAL)])+"]":"[sampling dist]"}function s(n){if("object"!==e(n))return r({TAG:1,_0:"Wrong type: "+f.toString(n)},Symbol.for("name"),"Error");var t=n.NAME;if("SymbolicDist"!==t)return"RenderedDist"===t?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n.VAL}},Symbol.for("name"),"Ok"):"Hash"===t?o._2(i.R.fmap,function(r){return{NAME:"Hash",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(r){var e=r[0];return o._2(i.R.fmap,function(r){return[e,r]},s(r[1]))},n.VAL))):"Array"===t?o._2(i.R.fmap,function(r){return{NAME:"Array",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,s,n.VAL))):r({TAG:1,_0:"Wrong type: "+f.toString(n)},Symbol.for("name"),"Error");var a=n.VAL;return"object"===e(a)&&"Float"===a.NAME?r({TAG:0,_0:{NAME:"Float",VAL:a.VAL}},Symbol.for("name"),"Ok"):r({TAG:0,_0:{NAME:"SamplingDist",VAL:{NAME:"SymbolicDist",VAL:a}}},Symbol.for("name"),"Ok")}function p(n,t,f){if("object"===e(t)){if("Array"===t.NAME){if("object"!==e(f))return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");if("Array"!==f.NAME)return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");var m=t.VAL;return o._2(i.R.fmap,function(r){return{NAME:"Array",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(r){return p(n,m,r)},f.VAL)))}if("object"!==e(f))return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");if("Hash"!==f.NAME)return r({TAG:1,_0:"fromNodeWithTypeCoercion error, sorry."},Symbol.for("name"),"Error");var y=f.VAL,c=o._2(i.A.fmap,function(r){var e=r[0];return[e,r[1],o._2(u.ExpressionTree.Hash.getByName,y,e)]},t.VAL);return o._2(i.R.fmap,function(r){return{NAME:"Hash",VAL:r}},o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(e){var t=e[2];if(void 0===t)return r({TAG:1,_0:"Hash parameter not present in hash."},Symbol.for("name"),"Error");var a=e[0];return o._2(i.R.fmap,function(r){return[a,r]},p(n,e[1],t))},c)))}if("Float"===t){var l=A(f);return void 0!==l?r({TAG:0,_0:{NAME:"Float",VAL:l}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Type Error: Expected float."},Symbol.for("name"),"Error")}if("SamplingDistribution"===t){var b=a.SamplingDistribution.renderIfIsNotSamplingDistribution(n,f);return o._2(i.R.bind,b,s)}var _=o._2(u.ExpressionTree.Render.render,n,f);return o._2(i.R.bind,_,s)}function y(o){return"object"===e(o)&&"Float"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not a float"},Symbol.for("name"),"Error")}function c(o){return"object"===e(o)&&"Array"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not an array"},Symbol.for("name"),"Error")}function l(o){return"object"===e(o)&&"Hash"===o.NAME?r({TAG:0,_0:o.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Not a named item"},Symbol.for("name"),"Error")}function b(o){if("object"!==e(o))return r({TAG:1,_0:"Cannot be converted into a distribution: "+m(o)},Symbol.for("name"),"Error");var n=o.NAME;if("SamplingDist"!==n)return"Float"===n?r({TAG:0,_0:{NAME:"SymbolicDist",VAL:{NAME:"Float",VAL:o.VAL}}},Symbol.for("name"),"Ok"):"RenderedDist"===n?r({TAG:0,_0:{NAME:"RenderedDist",VAL:o.VAL}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Cannot be converted into a distribution: "+m(o)},Symbol.for("name"),"Error");var t=o.VAL;return"RenderedDist"===t.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:t.VAL}},Symbol.for("name"),"Ok"):r({TAG:0,_0:{NAME:"SymbolicDist",VAL:t.VAL}},Symbol.for("name"),"Ok")}var _={toString:m,fromNode:s,fromNodeWithTypeCoercion:p,toFloat:y,toArray:c,toNamed:l,toDist:b};function T(r,e,o,n,t,i){return{name:r,inputTypes:e,outputType:o,run:n,shouldCoerceTypes:void 0===t||t}}function E(e,o){var n=i.A.length(o.inputTypes),t=i.A.length(e);return n===t?r({TAG:0,_0:e},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Wrong number of inputs. Expected"+i.I.toString(n)+". Got:"+i.I.toString(t)},Symbol.for("name"),"Error")}function d(r,e,t,a){return o._1(i.A.R.firstErrorOrOpen,o._2(i.A.fmap,function(e){var o=e[1];return t?p(r,e[0],o):s(o)},n.zip(e,a)))}function S(r,e,n){var t=n.shouldCoerceTypes,a=n.inputTypes;return o._2(i.R.bind,E(e,n),function(e){return d(r,a,t,e)})}function N(e,n,t){var a=o._2(i.R.bind,S(e,n,t),t.run);return 0===a.TAG?r({TAG:0,_0:a._0},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Function "+t.name+" error: "+a._0},Symbol.for("name"),"Error")}var V={make:T,_inputLengthCheck:E,_coerceInputNodes:d,inputsToTypedValues:S,run:N};function L(r,e){return n.getBy(r,function(r){return r.name===e})}function G(r,e,n,t){return o._2(i.O.fmap,function(r){return N(n,t,r)},L(r,e))}var v={findByName:L,findByNameAndRun:G},O={T:V,Ts:v};exports.getFloat=A,exports.TypedValue=_,exports.$$Function=O; +},{"rescript/lib/js/curry.js":"NSLD","rescript/lib/js/belt_Array.js":"yUxI","rescript/lib/js/caml_splice_call.js":"N3i9","../utility/E.bs.js":"xX5m","../expressionTree/PTypes.bs.js":"uF38","../expressionTree/ASTTypes.bs.js":"OH0m","../expressionTree/ExpressionTreeBasic.bs.js":"lpIF"}],"BBdU":[function(require,module,exports) { +"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(t)}function t(r,t,e){return t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}var e=require("rescript/lib/js/curry.js"),n=require("rescript/lib/js/caml_splice_call.js"),i=require("../utility/E.bs.js"),o=require("../distribution/Shape.bs.js"),a=require("../expressionTree/Operation.bs.js"),u=require("./TypeSystem.bs.js"),l=require("../symbolic/SymbolicDist.bs.js"),m=require("../expressionTree/ASTTypes.bs.js");function s(r){var o=n.spliceObjApply(",","concat",[e._2(i.A.fmap,u.TypedValue.toString,r)]);return console.log("Inputs were",o,r),t({TAG:1,_0:"Wrong inputs. The inputs were:"+o},Symbol.for("name"),"Error")}function A(r,e){return r<=0&&r1e4?"Sampling":"Analytical"}function y(r,e,i,u){var a=o.R.merge(t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,i),t.SamplingDistribution.renderIfIsNotSamplingDistribution(r,u));return n._2(o.R.bind,a,function(n){var o=n[1],i=n[0];return"Sampling"===d(i,o)?t.SamplingDistribution.combineShapesUsingSampling(r,e,i,o):b(r,e,i,o)})}function p(i,t,u,a){var s=m(t,u,a);return n._2(o.R.bind,s,function(n){return"object"===e(n)&&"SymbolicDist"===n.NAME?r({TAG:0,_0:n},Symbol.for("name"),"Ok"):y(i,t,u,a)})}var E={tryAnalyticalSimplification:m,combinationByRendering:b,nodeScore:l,choose:d,combine:y,operationToLeaf:p};function S(o,t,u){var s=n._2(f.ExpressionTree.Render.render,o,t),A=n._2(f.ExpressionTree.Render.render,o,u);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(function(r,e){return r+e},function(r,e){return a.combinePointwise(void 0,void 0,"CDF",function(r,e){return r+e},r,e)},function(r,e){return r+e},c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function _(o,t,u,a){var s=n._2(f.ExpressionTree.Render.render,t,u),A=n._2(f.ExpressionTree.Render.render,t,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var c=s._0;if("object"===e(c)&&"RenderedDist"===c.NAME&&0===A.TAG){var m=A._0;return"object"===e(m)&&"RenderedDist"===m.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:i.combinePointwise(void 0,void 0,o,c.VAL,m.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error")}return 0===A.TAG?r({TAG:1,_0:"Pointwise combination: rendering failed."},Symbol.for("name"),"Error"):r({TAG:1,_0:A._0},Symbol.for("name"),"Error")}function T(r,e,n,o){return"Add"===e?S(r,n,o):_("Exponentiate"===e?function(r,e){return Math.pow(r,e)}:function(r,e){return r*e},r,n,o)}var v={pointwiseAdd:S,pointwiseCombine:_,operationToLeaf:T};function L(r,n,o){if(void 0!==r){if(void 0!==n&&r>n)return{NAME:"Error",VAL:"Left truncation bound must be smaller than right truncation bound."}}else if(void 0===n)return{NAME:"Solution",VAL:o};if("object"!==e(o))return"NoSolution";if("SymbolicDist"!==o.NAME)return"NoSolution";var i=o.VAL;return"object"===e(i)&&"Uniform"===i.NAME?{NAME:"Solution",VAL:{NAME:"SymbolicDist",VAL:{NAME:"Uniform",VAL:A.Uniform.truncate(r,n,i.VAL)}}}:"NoSolution"}function R(o,t,u,a){var s=n._2(f.ExpressionTree.Render.ensureIsRendered,o,a);if(0!==s.TAG)return r({TAG:1,_0:s._0},Symbol.for("name"),"Error");var A=s._0;return"object"===e(A)&&"RenderedDist"===A.NAME?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._3(i.T.truncate,t,u,A.VAL)}},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Could not truncate distribution."},Symbol.for("name"),"Error")}function V(n,o,i,t){var u=L(o,i,t);return"object"===e(u)?"Error"===u.NAME?r({TAG:1,_0:u.VAL},Symbol.for("name"),"Error"):r({TAG:0,_0:u.VAL},Symbol.for("name"),"Ok"):R(n,o,i,t)}var N={trySimplification:L,truncateAsShape:R,operationToLeaf:V};function G(o,t){if("object"!==e(t))return f.ExpressionTree.evaluateAndRetry(o,G,t);var u=t.NAME;return"SymbolicDist"===u?r({TAG:0,_0:t},Symbol.for("name"),"Ok"):"RenderedDist"===u?r({TAG:0,_0:{NAME:"RenderedDist",VAL:n._1(i.T.normalize,t.VAL)}},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(o,G,t)}var M={operationToLeaf:G};function D(r,e,o){return n._4(s.$$Function.Ts.findByNameAndRun,c.all,r,e,o)}function g(r,e,i){var u=n._2(f.ExpressionTree.Environment.getFunction,e.environment,r);return n._2(o.R.bind,u,function(r){return t.$$Function.run(e,i,[r[0],r[1]])})}function j(r,e,i){return n._2(o.O.$$default,g(e,r,i),D(e,r,i))}function x(r,e,i){var t=n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(e){return n._2(r.evaluateNode,r,e)},i));return n._2(o.R.bind,t,function(n){return j(r,e,n)})}var O={_runHardcodedFunction:D,_runLocalFunction:g,_runWithEvaluatedInputs:j,run:x};function h(n,o){if("object"!==e(o))return f.ExpressionTree.evaluateAndRetry(n,h,o);var i=o.NAME;return"SymbolicDist"===i?r({TAG:0,_0:{NAME:"RenderedDist",VAL:A.T.toShape(n.samplingInputs.shapeLength,o.VAL)}},Symbol.for("name"),"Ok"):"Function"===i?r({TAG:1,_0:"Cannot render a function"},Symbol.for("name"),"Error"):"RenderedDist"===i?r({TAG:0,_0:o},Symbol.for("name"),"Ok"):f.ExpressionTree.evaluateAndRetry(n,h,o)}var w={operationToLeaf:h};function k(e,i){var t=i.NAME;if("RenderedDist"===t||"Function"===t||"SymbolicDist"===t)return r({TAG:0,_0:i},Symbol.for("name"),"Ok");if("FunctionCall"===t){var u=i.VAL,a=x(e,u[0],u[1]);return n._2(o.R.bind,a,function(r){return k(e,r)})}if("AlgebraicCombination"===t){var s=i.VAL;return p(e,s[0],s[1],s[2])}if("PointwiseCombination"===t){var A=i.VAL;return T(e,A[0],A[1],A[2])}if("Symbol"===t){var c=i.VAL,m=o.O.toResult("Undeclared variable "+c,n._2(f.ExpressionTree.Environment.get,e.environment,c));return n._2(o.R.bind,m,function(r){return k(e,r)})}if("Truncate"!==t)return"Hash"===t?n._2(o.R.fmap,function(r){return{NAME:"Hash",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){var i=r[0];return n._2(o.R.fmap,function(r){return[i,r]},k(e,r[1]))},i.VAL))):"Array"===t?n._2(o.R.fmap,function(r){return{NAME:"Array",VAL:r}},n._1(o.A.R.firstErrorOrOpen,n._2(o.A.fmap,function(r){return k(e,r)},i.VAL))):"Render"===t?h(e,i.VAL):G(e,i.VAL);var b=i.VAL;return V(e,b[0],b[1],b[2])}exports.AlgebraicCombination=E,exports.PointwiseCombination=v,exports.Truncate=N,exports.Normalize=M,exports.FunctionCall=O,exports.Render=w,exports.toLeaf=k; +},{"rescript/lib/js/curry.js":"NSLD","../utility/E.bs.js":"xX5m","../distribution/Shape.bs.js":"wbI6","./PTypes.bs.js":"uF38","../distribution/XYShape.bs.js":"Lf2V","../distribution/Continuous.bs.js":"CVcq","../typeSystem/TypeSystem.bs.js":"TKgk","../symbolic/SymbolicDist.bs.js":"wl7Z","./ASTTypes.bs.js":"OH0m","../typeSystem/HardcodedFunctions.bs.js":"BBdU"}],"H74a":[function(require,module,exports) { "use strict";function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(r)}function r(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var n=require("./PTypes.bs.js"),t=require("./ExpressionTreeBasic.bs.js"),o=require("./ExpressionTreeEvaluator.bs.js");function u(e,r){return{samplingInputs:e,environment:r,evaluateNode:o.toLeaf}}function i(e,r,n){return o.toLeaf({samplingInputs:e,environment:r,evaluateNode:o.toLeaf},n)}function a(n,t,o){var u=i(n,t,o);if(0!==u.TAG)return r({TAG:1,_0:u._0},Symbol.for("name"),"Error");var a=u._0;return"object"===e(a)&&"RenderedDist"===a.NAME?r({TAG:0,_0:a.VAL},Symbol.for("name"),"Ok"):r({TAG:1,_0:"Rendering failed."},Symbol.for("name"),"Error")}function s(e,r,t,u){var i={samplingInputs:e,environment:r,evaluateNode:o.toLeaf};return n.$$Function.run(i,t,u)}var f=t.toString;exports.toString=f,exports.envs=u,exports.toLeaf=i,exports.toShape=a,exports.runFunction=s; },{"./PTypes.bs.js":"uF38","./ExpressionTreeBasic.bs.js":"lpIF","./ExpressionTreeEvaluator.bs.js":"NgRJ"}],"uZ2e":[function(require,module,exports) { -"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/array.js"),t=require("rescript/lib/js/curry.js"),o=require("rescript/lib/js/caml_option.js"),i=require("rescript/lib/js/belt_MapString.js"),u=require("./utility/E.bs.js"),s=require("./distribution/DistPlus.bs.js"),a=require("./expressionTree/MathJsParser.bs.js"),l=require("./expressionTree/ExpressionTree.bs.js"),m=require("./expressionTree/ExpressionTypes.bs.js"),p={},f={sampleCount:void 0,outputXYPoints:void 0,kernelWidth:void 0,shapeLength:void 0};function c(e,r,n,t){return{squiggleString:r,samplingInputs:void 0!==e?e:f,environment:void 0!==n?o.valFromOption(n):m.ExpressionTree.Environment.empty}}var d={SamplingInputs:p,defaultRecommendedLength:100,defaultShouldDownsample:!0,empty:f,make:c};function b(e,r,n){return{squiggleString:e.squiggleString,samplingInputs:e.samplingInputs,environment:t._3(m.ExpressionTree.Environment.update,e.environment,r,function(e){return n})}}function v(e,r){return{graph:e,shape:r}}function A(e){return{sampleCount:t._2(u.O.$$default,1e4,e.samplingInputs.sampleCount),outputXYPoints:t._2(u.O.$$default,1e4,e.samplingInputs.outputXYPoints),kernelWidth:e.samplingInputs.kernelWidth,shapeLength:t._2(u.O.$$default,1e4,e.samplingInputs.shapeLength)}}function y(e,r){return l.toLeaf(A(e),e.environment,r)}function g(e,r){var n={contents:e};return t._1(u.A.R.firstErrorOrOpen,t._1(u.A.O.concatSomes,t._2(u.A.fmap,function(e){if("Expression"===e.NAME)return t._2(u.R.fmap,function(e){return[n.contents.environment,e]},y(n.contents,e.VAL));var r=e.VAL;n.contents=b(n.contents,r[0],r[1])},r)))}function _(e){var r=a.fromString(e.squiggleString);return t._2(u.R.bind,r,function(r){return g(e,r)})}function S(e,r){return s.make(r,e.squiggleString,void 0,void 0,void 0)}var T={addVariable:b,makeOutputs:v,makeInputs:A,runNode:y,runProgram:g,inputsToLeaf:_,outputToDistPlus:S};function E(n,t){if("object"!==r(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var o=t.NAME;if("SymbolicDist"!==o&&"Normalize"!==o)return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=y(n,{NAME:"Render",VAL:t});if(0!==i.TAG)return e({TAG:1,_0:i._0},Symbol.for("name"),"Error");var u=i._0;return"object"===r(u)&&"RenderedDist"===u.NAME?i:e({TAG:1,_0:"Didn't render, but intended to"},Symbol.for("name"),"Error")}function h(n,o,i){var s=E(n,i);return t._2(u.R.bind,s,function(t){if("object"===r(t)){var i=t.NAME;if("SymbolicDist"===i){var u=t.VAL;if("object"===r(u)&&"Float"===u.NAME)return e({TAG:0,_0:{NAME:"Float",VAL:u.VAL}},Symbol.for("name"),"Ok")}else{if("Function"===i)return e({TAG:0,_0:{NAME:"Function",VAL:[t.VAL,o]}},Symbol.for("name"),"Ok");if("RenderedDist"===i){var s=t.VAL,a=0;switch(0|s.TAG){case 1:var m=s._0.xyShape,p=m.xs;if(1!==p.length)a=2;else{var f=p[0],c=m.ys;if(1!==c.length)a=2;else{if(1===c[0])return e({TAG:0,_0:{NAME:"Float",VAL:f}},Symbol.for("name"),"Ok");a=2}}break;case 0:case 2:a=2}if(2===a)return e({TAG:0,_0:{NAME:"DistPlus",VAL:S(n,s)}},Symbol.for("name"),"Ok")}}}return e({TAG:1,_0:"Didn't output a rendered distribution. Format:"+l.toString(t)},Symbol.for("name"),"Error")})}function x(r,n){if(!n)return e({TAG:0,_0:0},Symbol.for("name"),"Ok");var o=t._1(r,n.hd);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var i=x(r,n.tl);return 0===i.TAG?e({TAG:0,_0:{hd:o._0,tl:i._0}},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function j(e){var r=_(e);return t._2(u.R.bind,r,function(r){return x(function(r){return h(e,r[0],r[1])},n.to_list(r))})}function L(e,r,n){var o=l.runFunction(A(e),e.environment,n,r),i=e.environment;return t._2(u.R.bind,o,function(r){return h(e,i,r)})}function k(e){return j(c({sampleCount:1e4,outputXYPoints:1e4,kernelWidth:void 0,shapeLength:1e3},e,o.some(i.fromArray([])),void 0))}exports.Inputs=d,exports.Internals=T,exports.renderIfNeeded=E,exports.coersionToExportedTypes=h,exports.mapM=x,exports.evaluateProgram=j,exports.evaluateFunction=L,exports.runAll=k; -},{"rescript/lib/js/array.js":"d4B1","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MapString.js":"mO07","./utility/E.bs.js":"xX5m","./distribution/DistPlus.bs.js":"A9pM","./expressionTree/MathJsParser.bs.js":"dGOd","./expressionTree/ExpressionTree.bs.js":"H74a","./expressionTree/ExpressionTypes.bs.js":"OH0m"}],"OXj9":[function(require,module,exports) { +"use strict";function e(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var n=require("rescript/lib/js/array.js"),t=require("rescript/lib/js/curry.js"),o=require("rescript/lib/js/caml_option.js"),i=require("rescript/lib/js/belt_MapString.js"),u=require("./utility/E.bs.js"),s=require("./distribution/DistPlus.bs.js"),a=require("./expressionTree/MathJsParser.bs.js"),l=require("./expressionTree/ExpressionTree.bs.js"),m=require("./expressionTree/ASTTypes.bs.js"),p={},f={sampleCount:void 0,outputXYPoints:void 0,kernelWidth:void 0,shapeLength:void 0};function c(e,r,n,t){return{squiggleString:r,samplingInputs:void 0!==e?e:f,environment:void 0!==n?o.valFromOption(n):m.ExpressionTree.Environment.empty}}var d={SamplingInputs:p,defaultRecommendedLength:100,defaultShouldDownsample:!0,empty:f,make:c};function b(e,r,n){return{squiggleString:e.squiggleString,samplingInputs:e.samplingInputs,environment:t._3(m.ExpressionTree.Environment.update,e.environment,r,function(e){return n})}}function v(e,r){return{graph:e,shape:r}}function A(e){return{sampleCount:t._2(u.O.$$default,1e4,e.samplingInputs.sampleCount),outputXYPoints:t._2(u.O.$$default,1e4,e.samplingInputs.outputXYPoints),kernelWidth:e.samplingInputs.kernelWidth,shapeLength:t._2(u.O.$$default,1e4,e.samplingInputs.shapeLength)}}function y(e,r){return l.toLeaf(A(e),e.environment,r)}function g(e,r){var n={contents:e};return t._1(u.A.R.firstErrorOrOpen,t._1(u.A.O.concatSomes,t._2(u.A.fmap,function(e){if("Expression"===e.NAME)return t._2(u.R.fmap,function(e){return[n.contents.environment,e]},y(n.contents,e.VAL));var r=e.VAL;n.contents=b(n.contents,r[0],r[1])},r)))}function _(e){var r=a.fromString(e.squiggleString);return t._2(u.R.bind,r,function(r){return g(e,r)})}function S(e,r){return s.make(r,e.squiggleString,void 0,void 0,void 0)}var T={addVariable:b,makeOutputs:v,makeInputs:A,runNode:y,runProgram:g,inputsToLeaf:_,outputToDistPlus:S};function E(n,t){if("object"!==r(t))return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var o=t.NAME;if("SymbolicDist"!==o&&"Normalize"!==o)return e({TAG:0,_0:t},Symbol.for("name"),"Ok");var i=y(n,{NAME:"Render",VAL:t});if(0!==i.TAG)return e({TAG:1,_0:i._0},Symbol.for("name"),"Error");var u=i._0;return"object"===r(u)&&"RenderedDist"===u.NAME?i:e({TAG:1,_0:"Didn't render, but intended to"},Symbol.for("name"),"Error")}function h(n,o,i){var s=E(n,i);return t._2(u.R.bind,s,function(t){if("object"===r(t)){var i=t.NAME;if("SymbolicDist"===i){var u=t.VAL;if("object"===r(u)&&"Float"===u.NAME)return e({TAG:0,_0:{NAME:"Float",VAL:u.VAL}},Symbol.for("name"),"Ok")}else{if("Function"===i)return e({TAG:0,_0:{NAME:"Function",VAL:[t.VAL,o]}},Symbol.for("name"),"Ok");if("RenderedDist"===i){var s=t.VAL,a=0;switch(0|s.TAG){case 1:var m=s._0.xyShape,p=m.xs;if(1!==p.length)a=2;else{var f=p[0],c=m.ys;if(1!==c.length)a=2;else{if(1===c[0])return e({TAG:0,_0:{NAME:"Float",VAL:f}},Symbol.for("name"),"Ok");a=2}}break;case 0:case 2:a=2}if(2===a)return e({TAG:0,_0:{NAME:"DistPlus",VAL:S(n,s)}},Symbol.for("name"),"Ok")}}}return e({TAG:1,_0:"Didn't output a rendered distribution. Format:"+l.toString(t)},Symbol.for("name"),"Error")})}function x(r,n){if(!n)return e({TAG:0,_0:0},Symbol.for("name"),"Ok");var o=t._1(r,n.hd);if(0!==o.TAG)return e({TAG:1,_0:o._0},Symbol.for("name"),"Error");var i=x(r,n.tl);return 0===i.TAG?e({TAG:0,_0:{hd:o._0,tl:i._0}},Symbol.for("name"),"Ok"):e({TAG:1,_0:i._0},Symbol.for("name"),"Error")}function j(e){var r=_(e);return t._2(u.R.bind,r,function(r){return x(function(r){return h(e,r[0],r[1])},n.to_list(r))})}function L(e,r,n){var o=l.runFunction(A(e),e.environment,n,r),i=e.environment;return t._2(u.R.bind,o,function(r){return h(e,i,r)})}function k(e){return j(c({sampleCount:1e4,outputXYPoints:1e4,kernelWidth:void 0,shapeLength:1e3},e,o.some(i.fromArray([])),void 0))}exports.Inputs=d,exports.Internals=T,exports.renderIfNeeded=E,exports.coersionToExportedTypes=h,exports.mapM=x,exports.evaluateProgram=j,exports.evaluateFunction=L,exports.runAll=k; +},{"rescript/lib/js/array.js":"d4B1","rescript/lib/js/curry.js":"NSLD","rescript/lib/js/caml_option.js":"dzFO","rescript/lib/js/belt_MapString.js":"mO07","./utility/E.bs.js":"xX5m","./distribution/DistPlus.bs.js":"A9pM","./expressionTree/MathJsParser.bs.js":"dGOd","./expressionTree/ExpressionTree.bs.js":"H74a","./expressionTree/ASTTypes.bs.js":"OH0m"}],"OXj9":[function(require,module,exports) { var r=require("./ProgramEvaluator.bs"),a=function(a){var u=r.runAll(a);return 0===u.TAG?{tag:"Ok",value:u._0}:{tag:"Error",value:u._0}};exports.runAll=a; },{"./ProgramEvaluator.bs":"uZ2e"}],"Focm":[function(require,module,exports) { var r=require("../distPlus/ProgramEvaluator.gen.js");exports.runMePlease=r.runAll; diff --git a/packages/squiggle-lang/dist/report.html b/packages/squiggle-lang/dist/report.html index f84ce526..3c25857c 100644 --- a/packages/squiggle-lang/dist/report.html +++ b/packages/squiggle-lang/dist/report.html @@ -42,7 +42,7 @@ margin-bottom: 10px; }