import Base import ./world.bend as W import ./lifetime_scope.bend as Scope import ./execution_composer_layout.bend as Layout type Operation<-S:Data> is Data: Assign{scope:Scope.Scope,handle:W.Handle} Cleanup{scope:Scope.Scope} type Commands<-Q:Type,-S:Data> is Type: Commands{assign:Q -> Scope.Scope -> W.Handle -> Q,cleanup:Q -> Scope.Scope -> Q} def provide(~S:Data,~Q:Type,~route:Layout.Route,~enqueue:Q -> Layout.Route -> Operation -> Q) -> Commands: Commands{queue => scope => handle => enqueue(queue,route,Assign{scope,handle}),queue => scope => enqueue(queue,route,Cleanup{scope})} def assign_field(~S:Data,~Q:Type,commands:Commands) -> Q -> Scope.Scope -> W.Handle -> Q: match commands: case Commands{assign,_}:assign def cleanup_field(~S:Data,~Q:Type,commands:Commands) -> Q -> Scope.Scope -> Q: match commands: case Commands{_,cleanup}:cleanup