ordinary_app_registration_run.bend

bendvy-ecs-core@0.1.0.1 · 40 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.1/trace_facts.bend as TraceFacts
3import bendvy-ecs-core@0.1.0.1/ordinary_app_registration_fields.bend as Records
4import bendvy-ecs-core@0.1.0.1/world.bend as W
5import bendvy-ecs-core@0.1.0.1/system.bend as Sys
6import bendvy-ecs-core@0.1.0.1/ordinary_query_declaration.bend as Query
7# Representation-only transport of the existing Sys.run discriminants.
8# No output, rejected argument or affine owner is duplicated or finalized here.
9type TransportResult<S:Data,World:Type,Args:Type,Error:Data,Out:Type,Token:Type> is Type:
10  Completed{token:Token,fields:Records.Fields<S>,outcome:Sys.Outcome<World,Error,Out>}
11  RegistrationRejected{token:Token,fields:Records.Fields<S>,world:World,args:Args}
12def returned(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,slot:String,clauses:List<&2,Query.Clause<S>>,kind:Records.RegistrationKind,registry:Sys.Registry<S,C,R,E,Args,Error,Out,runner>) -> Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Records.Fields<S>:
13  match registry:
14    case Sys.Registry{namespace,id,name,access,cursor}:(Records.Token{},Records.Fields{namespace,id,name,access,cursor,slot,clauses,kind})
15def completed(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,outcome:Sys.Outcome<W.World<S,C,R,E>,Error,Out>,result:Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Records.Fields<S>) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>>:
16  match result:
17    case (token,fields):Completed{token,fields,outcome}
18def rejected(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,world:W.World<S,C,R,E>,args:Args,result:Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Records.Fields<S>) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>>:
19  match result:
20    case (token,fields):RegistrationRejected{token,fields,world,args}
21def captured(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,slot:String,clauses:List<&2,Query.Clause<S>>,kind:Records.RegistrationKind,result:Sys.RunResult<S,C,R,E,Args,Error,Out,runner>) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>>:
22  match result:
23    case Sys.Completed{registry,outcome}:completed(~S,~C,~R,~E,~Args,~Error,~Out,~runner,outcome,returned(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,kind,registry))
24    case Sys.RegistrationRejected{registry,world,args}:rejected(~S,~C,~R,~E,~Args,~Error,~Out,~runner,world,args,returned(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,kind,registry))
25def restored(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,fields:Records.Fields<S>,world:W.World<S,C,R,E>,args:Args) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>>:
26  match fields:
27    case Records.Fields{namespace,id,name,access,cursor,slot,clauses,kind}:captured(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,kind,Sys.run(~S,~C,~R,~E,~Args,~Error,~Out,~runner,Sys.Registry{namespace,id,name,access,cursor},world,args))
28def run(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,token:Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>,fields:Records.Fields<S>,world:W.World<S,C,R,E>,args:Args) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>>:
29  match token:
30    case Records.Token{}:restored(~S,~C,~R,~E,~Args,~Error,~Out,~runner,fields,world,args)
31
32def captured_observed(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,slot:String,clauses:List<&2,Query.Clause<S>>,kind:Records.RegistrationKind,result:Sys.RunResult<S,C,R,E,Args,Error,Out,runner> & TraceFacts.State) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>> & TraceFacts.State:
33  match result:
34    case (result,trace):(captured(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,kind,result),trace)
35def restored_observed(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~observed:TraceFacts.State -> W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out> & TraceFacts.State,fields:Records.Fields<S>,trace:TraceFacts.State,world:W.World<S,C,R,E>,args:Args) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>> & TraceFacts.State:
36  match fields:
37    case Records.Fields{namespace,id,name,access,cursor,slot,clauses,kind}:captured_observed(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,kind,Sys.run_observed(~S,~C,~R,~E,~Args,~Error,~Out,~runner,~observed,Sys.Registry{namespace,id,name,access,cursor},trace,world,args))
38def run_observed(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~observed:TraceFacts.State -> W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out> & TraceFacts.State,token:Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>,fields:Records.Fields<S>,trace:TraceFacts.State,world:W.World<S,C,R,E>,args:Args) -> TransportResult<S,W.World<S,C,R,E>,Args,Error,Out,Records.Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>> & TraceFacts.State:
39  match token:
40    case Records.Token{}:restored_observed(~S,~C,~R,~E,~Args,~Error,~Out,~runner,~observed,fields,trace,world,args)