1 import Base 2 import ./world.bend as W 3 import ./compose.bend as Q 4 import ./transaction.bend as T 5 import ./local.bend as Local 6 import ./ordinary_capture_query.bend as O 7 import ./ordinary_query_declaration.bend as Decl 8 import ./ordinary_app_composer.bend as Build 9 import ./ordinary_app_records.bend as Pair 10 import ./ordinary_app_recipe.bend as Tree 11 import ./ordinary_app_observation_data.bend as DTO 12 import ./ordinary_app_registration_fields.bend as Fields 13 # Library-derived query bindings retain the real capture owner and reader cursor. 14 def fields(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Ops:Type -> Type,~A:Data,~U:Data,~Out:Data,~query:Decl.Declaration,Ops(Q.Frame)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> A -> H -> H & (L & (T.Outcome & Out)),owner:O.Owner) -> O.Owner & Fields.Fields: 15 match owner: 16 case O.Owner{Local.Instance{+ns,+id,+name,+access,capture},+cursor}:(O.Owner{Local.Instance{ns,id,name,access,capture},cursor},Fields.Fields{ns,id,name,access,cursor,name,Decl.clauses(~S,~Q.Frame,~Ops(Q.Frame),query),Fields.ComponentKind{}}) 17 def folded(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Ops:Type -> Type,~A:Data,~U:Data,~Out:Data,~query:Decl.Declaration,Ops(Q.Frame)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> A -> H -> H & (L & (T.Outcome & Out)),result:O.Owner & Fields.Fields) -> O.Owner & List<&2,Fields.Fields>: 18 match result: 19 case (owner,field):(owner,[field]) 20 def fold(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Ops:Type -> Type,~A:Data,~U:Data,~Out:Data,~query:Decl.Declaration,Ops(Q.Frame)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> A -> H -> H & (L & (T.Outcome & Out)),owner:O.Owner) -> O.Owner & List<&2,Fields.Fields>: 21 folded(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body,fields(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body,owner)) 22 type Appended is Type: 23 Appended{app:After} 24 AppendRejected{app:Before,capture:L} 25 def appended(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Ops:Type -> Type,~A:Data,~U:Data,~Out:Data,~query:Decl.Declaration,Ops(Q.Frame)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> A -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,previous:Previous,recipe:Tree.Recipe,Rows,observe>,debug:Bool,result:O.Registration,O.Owner,L>) -> Appended,Previous,Rows,observe,previousFold>,Build.Registered,Previous & O.Owner,Rows,observe,Pair.fold_pair(~S,~Previous,~O.Owner,~previousFold,~fold(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body))>,L>: 26 match result: 27 case O.Rejected{world,capture}:AppendRejected{Build.Registered{world,previous,recipe,debug},capture} 28 case O.Registered{world,owner}:Appended{Build.Registered{world,(previous,owner),recipe,debug}} 29 def register(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Ops:Type -> Type,~A:Data,~U:Data,~Out:Data,~query:Decl.Declaration,Ops(Q.Frame)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> A -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,app:Build.Registered,Previous,Rows,observe,previousFold>,name:String,capture:L) -> Appended,Previous,Rows,observe,previousFold>,Build.Registered,Previous & O.Owner,Rows,observe,Pair.fold_pair(~S,~Previous,~O.Owner,~previousFold,~fold(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body))>,L>: 30 match app: 31 case Build.Registered{world,previous,recipe,debug}:appended(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body,~Previous,~Rows,~observe,~previousFold,previous,recipe,debug,O.define(~S,~C,~R,~E,~L,~Ops,~A,~U,~Out,~query,~body,world,name,capture))