inspector_definition.bend
bendvy-ecs-core@0.1.0.1 · 22 lines · 0 definitions
1import Base
2import inspector.bend as I
3import inspector_metadata.bend as Meta
4import 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.
8type State<-S:Data,-Store:Type,-R:Type,-E:Data,-Ops:Type -> Type,-descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>,-Owner:Type> is Type:
9 State{owner:Owner}
10def metadata_field(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,definition:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>) -> Meta.Metadata<S>:
11 match definition:
12 case Meta.Definition{metadata,_}:metadata
13def metadata(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>) -> Meta.Metadata<S>:
14 metadata_field(~S,~Store,~R,~E,~Ops,descriptor)
15def plan(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>) -> I.Plan<S,Store,R,E,Ops>:
16 Meta.into_plan(~S,~I.Plan<S,Store,R,E,Ops>,descriptor)
17def attach(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>,~Owner:Type,owner:Owner) -> State<S,Store,R,E,Ops,descriptor,Owner>:
18 State{owner}
19def read(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>,~Owner:Type,state:State<S,Store,R,E,Ops,descriptor,Owner>) -> State<S,Store,R,E,Ops,descriptor,Owner> & Meta.Metadata<S>:
20 (state,metadata(~S,~Store,~R,~E,~Ops,~descriptor))
21def invoke(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition<S,I.Plan<S,Store,R,E,Ops>>,~Owner:Type,~A:Data,~U:Data,~Out:Data,~body:@-H:Type -> @-caps:Ops(H) -> A -> H -> H & Result<&2,&2,U,Out>,state:State<S,Store,R,E,Ops,descriptor,Owner>,instance:I.Instance<S>,args:A,world:W.World<S,Store,R,E>) -> State<S,Store,R,E,Ops,descriptor,Owner> & I.Observed<S,Store,R,E,U,Out>:
22 (state,I.run(~S,~Store,~R,~E,~Ops,~A,~U,~Out,~plan(~S,~Store,~R,~E,~Ops,~descriptor),~body,instance,args,world))