ordinary_app_optional_resource_run.bend
bendvy-ecs-core@0.1.0.1 · 34 lines · 0 definitions
1import Base
2import bendvy-ecs-core@0.1.0.1/ordinary_app_composer.bend as Build
3import bendvy-ecs-core@0.1.0.1/ordinary_app_registration_fields.bend as Records
4import bendvy-ecs-core@0.1.0.1/ordinary_app_records.bend as Leaf
5import bendvy-ecs-core@0.1.0.1/ordinary_app_recipe.bend as Tree
6import bendvy-ecs-core@0.1.0.1/ordinary_app_observation_data.bend as DTO
7import bendvy-ecs-core@0.1.0.1/ordinary_system.bend as Ordinary
8import bendvy-ecs-core@0.1.0.1/world.bend as W
9import bendvy-ecs-core@0.1.0.1/system.bend as Sys
10import bendvy-ecs-core@0.1.0.1/check.bend as K
11import bendvy-ecs-core@0.1.0.1/ordinary_query_declaration.bend as Query
12# Run the actual newest retained Registry. Registration refusal remains distinct
13# from the existing runner error; no replacement error or transaction is added.
14type Status<Out:Data> is Data:
15 Succeeded{output:Out}
16 Failed{error:K.Error}
17 RegistrationRejected{}
18def completed(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Data,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,result:Sys.RunResult<S,C,R,E,Args,K.Error,Out,runner>) -> W.World<S,C,R,E> & (Sys.Registry<S,C,R,E,Args,K.Error,Out,runner> & Status<Out>):
19 match result:
20 case Sys.Completed{registry,Sys.Succeeded{world,output}}:(world,(registry,Succeeded{output}))
21 case Sys.Completed{registry,Sys.Failed{world,error}}:(world,(registry,Failed{error}))
22 case Sys.RegistrationRejected{registry,world,_}:(world,(registry,RegistrationRejected{}))
23def repacked(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Data,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>> -> (Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>) & List<&2,Records.Fields<S>>,world:W.World<S,C,R,E>,owners:Owners,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,debug:Bool,status:Status<Out>,result:Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>> & Records.Fields<S>) -> Build.Registered<S,W.World<S,C,R,E>,Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>,Rows,observe,fold> & Status<Out>:
24 match result:
25 case (token,fields):(Build.Registered{world,(owners,Leaf.Record{token,fields}),recipe,debug},status)
26def returned(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Data,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>> -> (Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>) & List<&2,Records.Fields<S>>,owners:Owners,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,debug:Bool,slot:String,clauses:List<&2,Query.Clause<S>>,result:W.World<S,C,R,E> & (Sys.Registry<S,C,R,E,Args,K.Error,Out,runner> & Status<Out>)) -> Build.Registered<S,W.World<S,C,R,E>,Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>,Rows,observe,fold> & Status<Out>:
27 match result:
28 case (world,(registry,status)):repacked(~S,~C,~R,~E,~Args,~Out,~runner,~Owners,~Rows,~observe,~fold,world,owners,recipe,debug,status,Records.field_registry(~S,~C,~R,~E,~Args,~K.Error,~Out,~runner,slot,clauses,registry))
29def restored(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Data,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>> -> (Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>) & List<&2,Records.Fields<S>>,world:W.World<S,C,R,E>,owners:Owners,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,debug:Bool,args:Args,result:Ordinary.Owner<S,Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>) -> Build.Registered<S,W.World<S,C,R,E>,Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>,Rows,observe,fold> & Status<Out>:
30 match result:
31 case Ordinary.Owner{registry,slot,clauses}:returned(~S,~C,~R,~E,~Args,~Out,~runner,~Owners,~Rows,~observe,~fold,owners,recipe,debug,slot,clauses,completed(~S,~C,~R,~E,~Args,~Out,~runner,Sys.run(~S,~C,~R,~E,~Args,~K.Error,~Out,~runner,registry,world,args)))
32def run_latest(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Data,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>> -> (Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>) & List<&2,Records.Fields<S>>,app:Build.Registered<S,W.World<S,C,R,E>,Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>,Rows,observe,fold>,args:Args) -> Build.Registered<S,W.World<S,C,R,E>,Owners & Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>>>,Rows,observe,fold> & Status<Out>:
33 match app:
34 case Build.Registered{world,(owners,Leaf.Record{token,fields}),recipe,debug}:restored(~S,~C,~R,~E,~Args,~Out,~runner,~Owners,~Rows,~observe,~fold,world,owners,recipe,debug,args,Records.restore_component(~S,~C,~R,~E,~Args,~K.Error,~Out,~runner,token,fields))