ordinary_app_hierarchy.bend
bendvy-ecs-core@0.1.0.4 · 73 lines · 11 definitions
1import Base
2import bendvy-ecs-core@0.1.0.4/ordinary_app_relation.bend as Relation
3import bendvy-ecs-core@0.1.0.4/ordinary_app_composer.bend as Build
4import bendvy-ecs-core@0.1.0.4/ordinary_app_observation_data.bend as DTO
5import bendvy-ecs-core@0.1.0.4/ordinary_app_registration_fields.bend as Fields
6import bendvy-ecs-core@0.1.0.4/relation_failure_reader.bend as Ord
7import bendvy-ecs-core@0.1.0.4/relation_types.bend as G
8import bendvy-ecs-core@0.1.0.4/relation_reorder.bend as Reorder
9import bendvy-ecs-core@0.1.0.4/hierarchy_traversal_provider.bend as H
10import bendvy-ecs-core@0.1.0.4/hierarchy_provider.bend as Path
11import bendvy-ecs-core@0.1.0.4/hierarchy_traversal.bend as Traversal
12import bendvy-ecs-core@0.1.0.4/relation_providers.bend as P
13import bendvy-ecs-core@0.1.0.4/relation_commands.bend as A
14import bendvy-ecs-core@0.1.0.4/transaction.bend as Tx
15import bendvy-ecs-core@0.1.0.4/world.bend as W
16
17
18
19
20def declaration(~S:Data,hierarchy:G.HierarchyDescriptor<S>) -> Ord.Declaration<S>:
21 Ord.relation(~S,Reorder.descriptor(~S,hierarchy))
22
23
24def Application(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>) -> Type:
25 Relation.Application(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold)
26
27
28
29def install(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Build.Registered<S,Relation.World(~S,~C,~R,~E),Owners,Rows,prior,fold>) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold):
30 Relation.install(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold,app)
31def returned(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,~Value:Data,owners:Owners,recipe:Relation.Recipe(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold),debug:Bool,result:Relation.World(~S,~C,~R,~E) & Value) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & Value:
32 match result:
33 case (world,value):(Build.Registered{world,owners,recipe,debug},value)
34
35
36
37def root_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),target:W.Handle<S>) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & Maybe<&2,W.Handle<S>>:
38 match app:
39 case Build.Registered{world,owners,recipe,debug}:returned(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold,~Maybe<&2,W.Handle<S>>,owners,recipe,debug,H.lookup_root(~S,~C,~R,~E,~hierarchy,world,target))
40
41
42
43def ancestors_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),target:W.Handle<S>) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & Maybe<&2,Path.Path<S>>:
44 match app:
45 case Build.Registered{world,owners,recipe,debug}:returned(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold,~Maybe<&2,Path.Path<S>>,owners,recipe,debug,H.lookup_ancestors(~S,~C,~R,~E,~hierarchy,world,target))
46
47
48
49
50def descendants_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),target:W.Handle<S>,order:Traversal.Order) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & Maybe<&2,Path.Path<S>>:
51 match app:
52 case Build.Registered{world,owners,recipe,debug}:returned(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold,~Maybe<&2,Path.Path<S>>,owners,recipe,debug,H.lookup_descendants(~S,~C,~R,~E,~hierarchy,world,H.Descendants{target,order}))
53
54
55
56def relate_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,~Error:Data,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),targets:P.Targets<S>,outcome:Tx.Outcome<Error>) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & DTO.Product<A.QueueStatus,Tx.Outcome<Error>>:
57 Relation.relate_app(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold,~Error,app,targets,outcome)
58
59
60def barrier_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold)) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold):
61 Relation.barrier_app(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold,app)
62
63
64def snapshot_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),flag:Bool) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & Maybe<&2,DTO.Product<List<&2,DTO.Binding<S>>,DTO.Observation<Relation.ObservedRows(~S,~Rows)>>>:
65 Relation.snapshot_app(~S,~C,~R,~E,~declaration(~S,hierarchy),~Owners,~Rows,~prior,~fold,app,flag)
66
67
68
69
70
71def reorder_app(~S:Data,~C:Type,~R:Type,~E:Data,~hierarchy:G.HierarchyDescriptor<S>,~Owners:Type,~Rows:Data,~prior:Relation.World(~S,~C,~R,~E) -> Relation.World(~S,~C,~R,~E) & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Fields.Fields<S>>,~Error:Data,app:Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold),args:Reorder.Args<S>,outcome:Tx.Outcome<Error>) -> Application(~S,~C,~R,~E,~hierarchy,~Owners,~Rows,~prior,~fold) & DTO.Product<A.QueueStatus,Tx.Outcome<Error>>:
72 match app:
73 case Build.Registered{world,owners,recipe,debug}:Relation.queued(~S,~C,~R,~E,~declaration(~S,hierarchy),~Relation.builtin_row(~S),~Owners,~Rows,~prior,~fold,~Error,owners,recipe,debug,outcome,Reorder.invoke(~S,~C,~R,~E,~hierarchy,~A.QueueStatus,~Reorder.body(~S),args,Tx.begin(~Relation.World(~S,~C,~R,~E),~A.Notice<S,E>,world)))