1 import Base 2 import inspector.bend as I 3 import inspector_metadata.bend as Meta 4 import world.bend as W 5 6 # Unchecked extraction draft. Descriptor is trusted closed schema setup; 7 # arbitrary runtime owner is threaded once, never captured by the callback. 8 type State<-S:Data,-Store:Type,-R:Type,-E:Data,-Ops:Type -> Type,-descriptor:Meta.Definition>,-Owner:Type> is Type: 9 State{owner:Owner} 10 def metadata_field(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,definition:Meta.Definition>) -> Meta.Metadata: 11 match definition: 12 case Meta.Definition{metadata,_}:metadata 13 def metadata(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>) -> Meta.Metadata: 14 metadata_field(~S,~Store,~R,~E,~Ops,descriptor) 15 def plan(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>) -> I.Plan: 16 Meta.into_plan(~S,~I.Plan,descriptor) 17 def attach(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,owner:Owner) -> State: 18 State{owner} 19 def read(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,state:State) -> State & Meta.Metadata: 20 (state,metadata(~S,~Store,~R,~E,~Ops,~descriptor)) 21 def invoke(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,~A:Data,~U:Data,~Out:Data,~body:@-H:Type -> @-caps:Ops(H) -> A -> H -> H & Result<&2,&2,U,Out>,state:State,instance:I.Instance,args:A,world:W.World) -> State & I.Observed: 22 (state,I.run(~S,~Store,~R,~E,~Ops,~A,~U,~Out,~plan(~S,~Store,~R,~E,~Ops,~descriptor),~body,instance,args,world))