ordinary_app_schema.bend
bendvy-ecs-core@0.1.0.4 · 43 lines · 7 definitions
1import Base
2import bendvy-ecs-core@0.1.0.4/world.bend as W
3import bendvy-ecs-core@0.1.0.4/ordinary_schema.bend as Schema
4import bendvy-ecs-core@0.1.0.4/schema_fragments.bend as Fragment
5import bendvy-ecs-core@0.1.0.4/ordinary_app_composer.bend as Build
6import bendvy-ecs-core@0.1.0.4/ordinary_app_registration_fields.bend as Records
7import bendvy-ecs-core@0.1.0.4/ordinary_app_observation_data.bend as DTO
8
9
10
11
12type Application<S:Data,C:Type,R:Type,E:Data,Owners:Type,Rows:Data,-observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,-fold:Owners -> Owners & List<&2,Records.Fields<S>>> is Type:
13 Application{schema:Schema.Schema<S,C,R>,app:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold>}
14
15
16
17type Description<S:Data,Rows:Data> is Data:
18 Description{schema:List<&2,Fragment.Entry<S>>,registered:DTO.Product<List<&2,DTO.Binding<S>>,DTO.Observation<Rows>>}
19
20
21def attached(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,schema:Schema.Schema<S,C,R>,app:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold>) -> Application<S,C,R,E,Owners,Rows,observe,fold>:
22 Application{schema,app}
23
24
25def enabled(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,value:Application<S,C,R,E,Owners,Rows,observe,fold>,flag:Bool) -> Application<S,C,R,E,Owners,Rows,observe,fold>:
26 match value:
27 case Application{schema,app}:Application{schema,Build.enabled(~S,~W.World<S,C,R,E>,~Owners,~Rows,~observe,~fold,app,flag)}
28def observed(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,+schema:Schema.Schema<S,C,R>,result:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold> & Maybe<&2,DTO.Product<List<&2,DTO.Binding<S>>,DTO.Observation<Rows>>>) -> Application<S,C,R,E,Owners,Rows,observe,fold> & Maybe<&2,Description<S,Rows>>:
29 match result:
30 case (app,None{}):(Application{schema,app},None{})
31 case (app,Some{view}):(Application{schema,app},Some{Description{Schema.entries(~S,~C,~R,schema),view}})
32
33
34
35def snapshot(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,value:Application<S,C,R,E,Owners,Rows,observe,fold>) -> Application<S,C,R,E,Owners,Rows,observe,fold> & Maybe<&2,Description<S,Rows>>:
36 match value:
37 case Application{schema,app}:observed(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,schema,Build.snapshot(~S,~W.World<S,C,R,E>,~Owners,~Rows,~observe,~fold,app))
38
39
40
41
42def create(~S:Data,~C:Type,~R:Type,~E:Data,~empty:Unit -> C,schema:Schema.Schema<S,C,R>,factory:W.Factory,resource:R) -> Schema.Schema<S,C,R> & W.Creation<S,C,R,E>:
43 (schema,W.create(~S,~C,~R,~E,~empty,factory,resource))