def replace

bendvy-ecs-core@0.1.0.4 · ordinary_recovery_resource_field.bend:30

import bendvy-ecs-core@0.1.0.4/ordinary_recovery_resource_field.bend as OrdinaryRecoveryResourceField
import Base
import bendvy-ecs-core@0.1.0.4/world.bend as W
import bendvy-ecs-core@0.1.0.4/owner_product.bend as Product
import bendvy-ecs-core@0.1.0.4/ordinary_recoverable_array_resource.bend as F
import bendvy-ecs-core@0.1.0.4/recoverable_array.bend as A
import bendvy-ecs-core@0.1.0.4/recoverable_array_owner.bend as AO
import bendvy-ecs-core@0.1.0.4/world_resource_owner.bend as WR

30# Advanced recoverable replacement: consume incoming Array<P>, install it in
31# the selected field and journal the displaced array in the shared recovery path.
32# Commit returns displaced owners; rollback restores originals and returns displaced
33# replacements through the declaration recovery result, not a duplicate live owner.
34def replace(~S:Data,~C:Type,~E:Data,~Capture:Type,~R:Type,~P:Type,~FieldRest:Type,~fieldLens:Product.Lens<R,Array<P>,FieldRest>,~All:Type,~Rest:Type,~path:Product.Lens<All,List<A.Record<P>>,Rest>,frame:F.Frame<Product.Owner<W.World<S,C,R,E>,Capture>,All>,incoming:Array<P>) -> F.Frame<Product.Owner<W.World<S,C,R,E>,Capture>,All>:
35  match frame:
36    case F.Frame{state,journal}:replaced(~S,~C,~E,~Capture,~R,~P,~FieldRest,~fieldLens,~All,~Rest,~path,AO.replace(~Product.Owner<W.World<S,C,R,E>,Capture>,~P,~((Capture & WR.Rest<S,C,R,E>) & FieldRest),~target(~S,~C,~E,~Capture,~R,~P,~FieldRest,~fieldLens),~All,~Rest,~path,state,journal,incoming))

Uses (12)

Used by (1)