def sum_fold

bend-collections-laws-math@1.0.0.0 · proofs/math/typed/float.bend:77

import bend-collections-laws-math@1.0.0.0/proofs/math/typed/float.bend as Float
import Base
import bend-collections-laws-math@1.0.0.0/spec/math/generic.bend as SG
import bend-collections-laws-math@1.0.0.0/src/math/generic.bend as G
import bend-collections-laws-math@1.0.0.0/src/math/num.bend as N

77def sum_fold(~T: Data, ~op: N.Op<T> -> T, ~test: N.Test<T> -> Bool, ~ao: NoAddOver(~T, ~test), xs: List<&2, T>, +acc: T) -> {G.sum_go(~T, ~op, ~test, xs, Some{acc}) == Some{SG.fold_add(~T, ~op, xs, acc)} : Maybe<&2, T>}:
78  match xs:
79    case Nil{}:
80      {==}
81    case Con{+x, t}:
82      %Equal.sym(Bool, test(N.AddOver{acc, x}), False{}, ao(acc, x)) : {G.sum_go(~T, ~op, ~test, t, G.fits(T, _, op(N.Add{acc, x}))) == Some{SG.fold_add(~T, ~op, t, op(N.Add{acc, x}))} : Maybe<&2, T>}
83      sum_fold(~T, ~op, ~test, ~ao, t, op(N.Add{acc, x}))

Uses (10)

Used by (1)