def retained_result_value
bendtorch-core@0.1.0.0 · src/tensor/construction_contract_PROOF.bend:214
import bendtorch-core@0.1.0.0/src/tensor/construction_contract_PROOF.bend as ConstructionContractPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/allocation_spec.bend as Allocation
import bendtorch-core@0.1.0.0/src/tensor/observation.bend as Observation
214def retained_result_value(+shape: Shape.Shape, +fill: F32, +index: U32, +other: U32,
215 result: Result<&2, &1, Storage.Error, Storage.Storage>,
216 counted: {Allocation.storage_length(result) == Some{Shape.elements(shape)} : Maybe<&2, Nat>},
217 kept: {Lifecycle.read_value(Storage.get(StorageLaws.kept(StorageLaws.created.of(result), index), other)) == Some{fill} : Maybe<&2, F32>}) ->
218 {Observation.after_value(shape, index, other, Core.new_result(shape, result)) == Some{fill} : Maybe<&2, F32>}:
219 match result:
220 case Fail{error}:
221 Empty.absurd({None{} == Some{fill} : Maybe<&2, F32>}, Arith.clash(Equal.cong(Maybe<&2, Nat>, Bool,
222 value => Maybe.is_some(&2, Nat, value), None{}, Some{Shape.elements(shape)}, counted)))
223 case Done{storage}:
224 attach_value(shape, fill, index, other, storage,
225 Equal.cong(Maybe<&2, Nat>, Nat, value => Maybe.default(&2, Nat, value, 0n),
226 Some{Lifecycle.logical_length(storage)}, Some{Shape.elements(shape)}, counted), kept)