Make typechecker happy

Value: [1e-7 to 1e-3]
This commit is contained in:
Quinn Dougherty 2022-05-02 11:55:13 -04:00
parent 58c885f963
commit e2762a0f62
3 changed files with 7 additions and 6 deletions

View File

@ -62,7 +62,7 @@ let reduce = (
fn: (float, float) => result<float, 'e>, fn: (float, float) => result<float, 'e>,
discreteShapes: array<PointSetTypes.discreteShape>, discreteShapes: array<PointSetTypes.discreteShape>,
): result<t, 'e> => { ): result<t, 'e> => {
let merge = combinePointwise(~integralSumCachesFn, fn) let merge = combinePointwise(~integralSumCachesFn, ~fn)
discreteShapes |> E.A.R.foldM(merge, empty) 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 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 minX = shapeFn(XYShape.T.minX)
let maxX = shapeFn(XYShape.T.maxX) let maxX = shapeFn(XYShape.T.maxX)
let toDiscreteProbabilityMassFraction = _ => 1.0 let toDiscreteProbabilityMassFraction = _ => 1.0
@ -230,7 +231,7 @@ module T = Dist({
let logScore = (base: t, reference: t) => { let logScore = (base: t, reference: t) => {
combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference) combinePointwise(~fn=PointSetDist_Scoring.LogScoring.logScore, base, reference)
|> integralEndY |> E.R2.bind(integralEndYResult)
|> (r => Ok(r)) // |> (r => Ok(r))
} }
}) })

View File

@ -44,7 +44,7 @@ let combinePointwise = (
t2: t, t2: t,
): result<t, 'e> => { ): result<t, 'e> => {
let reducedDiscrete = 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 = let reducedContinuous =
[t1, t2] [t1, t2]

View File

@ -86,7 +86,7 @@ let combinePointwise = (
| (Discrete(m1), Discrete(m2)) => | (Discrete(m1), Discrete(m2)) =>
Discrete.combinePointwise( Discrete.combinePointwise(
~integralSumCachesFn, ~integralSumCachesFn,
fn, ~fn,
m1, m1,
m2, m2,
)->E.R2.fmap(x => PointSetTypes.Discrete(x)) )->E.R2.fmap(x => PointSetTypes.Discrete(x))