diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res index 410f49bf..59858420 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Discrete.res @@ -164,7 +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 integralEndYResult = (t: t) => t->integralEndY->Ok let minX = shapeFn(XYShape.T.minX) let maxX = shapeFn(XYShape.T.maxX) let toDiscreteProbabilityMassFraction = _ => 1.0 @@ -230,8 +230,9 @@ module T = Dist({ } let logScore = (base: t, reference: t) => { - combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) - |> E.R2.bind(integralEndYResult) + combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) |> E.R2.bind( + integralEndYResult, + ) // |> (r => Ok(r)) } }) diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res index e1b3173c..15da318d 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Distributions.res @@ -33,7 +33,7 @@ module type dist = { let mean: t => float let variance: t => float - let logScore: (t,t) => result + let logScore: (t, t) => result } module Dist = (T: dist) => { diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res index 3eb7b3f2..3d36d421 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/Mixed.res @@ -44,7 +44,11 @@ let combinePointwise = ( t2: t, ): result => { let reducedDiscrete = - [t1, t2] |> E.A.fmap(toDiscrete) |> E.A.O.concatSomes |> Discrete.reduce(~integralSumCachesFn, fn) |> E.R.toExn("foo") + [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_Scoring.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res index b55d2677..40ead2ce 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist_Scoring.res @@ -4,4 +4,4 @@ module LogScoring = { let logScore = (a: float, b: float): result => Ok( Js.Math.log2(Js.Math.abs_float(a /. b)), ) -} \ No newline at end of file +} diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index cd757bd5..4dd78848 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -212,9 +212,8 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option< a, )->Some | ("normalize", [EvDistribution(dist)]) => Helpers.toDistFn(Normalize, dist) - | ("logScore", [EvDistribution(a), EvDistribution(b)]) => Some( - runGenericOperation(FromDist(ToScore(LogScore(b)), a)), - ) + | ("logScore", [EvDistribution(a), EvDistribution(b)]) => + Some(runGenericOperation(FromDist(ToScore(LogScore(b)), a))) | ("isNormalized", [EvDistribution(dist)]) => Helpers.toBoolFn(IsNormalized, dist) | ("toPointSet", [EvDistribution(dist)]) => Helpers.toDistFn(ToPointSet, dist) | ("scaleLog", [EvDistribution(dist)]) => diff --git a/packages/squiggle-lang/src/rescript/Utility/XYShape.res b/packages/squiggle-lang/src/rescript/Utility/XYShape.res index 55b7717c..a90c68e5 100644 --- a/packages/squiggle-lang/src/rescript/Utility/XYShape.res +++ b/packages/squiggle-lang/src/rescript/Utility/XYShape.res @@ -96,7 +96,7 @@ module T = { let fromZippedArray = (pairs: array<(float, float)>): t => pairs |> Belt.Array.unzip |> fromArray let equallyDividedXs = (t: t, newLength) => E.A.Floats.range(minX(t), maxX(t), newLength) let toJs = (t: t) => {"xs": t.xs, "ys": t.ys} - let filterYValues = (fn, t: t): t => t |> zip |> E.A.filter(((_,y)) => fn(y)) |> fromZippedArray + let filterYValues = (fn, t: t): t => t |> zip |> E.A.filter(((_, y)) => fn(y)) |> fromZippedArray module Validator = { let fnName = "XYShape validate"