From e2762a0f62243f7c1b142942f602a84c76e14413 Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Mon, 2 May 2022 11:55:13 -0400 Subject: [PATCH] Make typechecker happy Value: [1e-7 to 1e-3] --- .../src/rescript/Distributions/PointSetDist/Discrete.res | 7 ++++--- .../src/rescript/Distributions/PointSetDist/Mixed.res | 2 +- .../rescript/Distributions/PointSetDist/PointSetDist.res | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res index 750c6a1c..410f49bf 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res @@ -62,7 +62,7 @@ let reduce = ( fn: (float, float) => result, discreteShapes: array, ): result => { - let merge = combinePointwise(~integralSumCachesFn, fn) + let merge = combinePointwise(~integralSumCachesFn, ~fn) discreteShapes |> E.A.R.foldM(merge, empty) } @@ -164,6 +164,7 @@ module T = Dist({ } let integralEndY = (t: t) => t.integralSumCache |> E.O.default(t |> integral |> Continuous.lastY) + let integralEndYResult = (t: t) => t -> integralEndY -> Ok let minX = shapeFn(XYShape.T.minX) let maxX = shapeFn(XYShape.T.maxX) let toDiscreteProbabilityMassFraction = _ => 1.0 @@ -230,7 +231,7 @@ module T = Dist({ let logScore = (base: t, reference: t) => { combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) - |> integralEndY - |> (r => Ok(r)) + |> E.R2.bind(integralEndYResult) + // |> (r => Ok(r)) } }) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index e57b9ed6..3eb7b3f2 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -44,7 +44,7 @@ let combinePointwise = ( t2: t, ): result => { let reducedDiscrete = - [t1, t2] |> E.A.fmap(toDiscrete) |> E.A.O.concatSomes |> Discrete.reduce(~integralSumCachesFn) + [t1, t2] |> E.A.fmap(toDiscrete) |> E.A.O.concatSomes |> Discrete.reduce(~integralSumCachesFn, fn) |> E.R.toExn("foo") let reducedContinuous = [t1, t2] diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res index ad314766..d7baad9f 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res @@ -86,7 +86,7 @@ let combinePointwise = ( | (Discrete(m1), Discrete(m2)) => Discrete.combinePointwise( ~integralSumCachesFn, - fn, + ~fn, m1, m2, )->E.R2.fmap(x => PointSetTypes.Discrete(x)) @@ -256,4 +256,4 @@ let toSparkline = (t: t, bucketCount): resultE.O2.fmap(Continuous.downsampleEquallyOverX(bucketCount)) ->E.O2.toResult(PointSetTypes.CannotSparklineDiscrete) - ->E.R2.fmap(r => Continuous.getShape(r).ys->Sparklines.create()) \ No newline at end of file + ->E.R2.fmap(r => Continuous.getShape(r).ys->Sparklines.create())