execution_lifetime_scope_command.bend source
execution_lifetime_scope_command.bend on the hub · documented module
import Baseimport ./world.bend as Wimport ./lifetime_scope.bend as Scopeimport ./execution_composer_layout.bend as Layouttype Operation<-S:Data> is Data: Assign{scope:Scope.Scope<S>,handle:W.Handle<S>} Cleanup{scope:Scope.Scope<S>}type Commands<-Q:Type,-S:Data> is Type: Commands{assign:Q -> Scope.Scope<S> -> W.Handle<S> -> Q,cleanup:Q -> Scope.Scope<S> -> Q}def provide(~S:Data,~Q:Type,~route:Layout.Route,~enqueue:Q -> Layout.Route -> Operation<S> -> Q) -> Commands<Q,S>: 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,S>) -> Q -> Scope.Scope<S> -> W.Handle<S> -> Q: match commands: case Commands{assign,_}:assigndef cleanup_field(~S:Data,~Q:Type,commands:Commands<Q,S>) -> Q -> Scope.Scope<S> -> Q: match commands: case Commands{_,cleanup}:cleanup