def replace

bendvy-ecs-core@0.1.0.4 · ordinary_recovery_resource.bend:26

import bendvy-ecs-core@0.1.0.4/ordinary_recovery_resource.bend as OrdinaryRecoveryResource
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

26# Replace the whole Array<P> resource in the shared recovery journal.
27# Consumes incoming array and returns frame; commit recovers the displaced
28# array, rollback restores it and recovers the replacement. Capture and other
29# World owners remain siblings, not independent copies.
30def replace(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~All:Type,~Rest:Type,~path:Product.Lens<All,List<A.Record<P>>,Rest>,frame:F.Frame<Product.Owner<W.World<S,C,Array<P>,E>,Capture>,All>,incoming:Array<P>) -> F.Frame<Product.Owner<W.World<S,C,Array<P>,E>,Capture>,All>:
31  match frame:
32    case F.Frame{state,journal}:replaced(~S,~C,~E,~Capture,~P,~All,~Rest,~path,AO.replace(~Product.Owner<W.World<S,C,Array<P>,E>,Capture>,~P,~(Capture & WR.Rest<S,C,Array<P>,E>),~target(~S,~C,~E,~Capture,~P),~All,~Rest,~path,state,journal,incoming))

Uses (12)

Used by (1)