ordinary_app_optional_resource.bend source
ordinary_app_optional_resource.bend on the hub · documented module
import Baseimport ./ordinary_query_declaration.bend as Queryimport ./ordinary_app_composer.bend as Buildimport ./ordinary_app_registration_fields.bend as Recordsimport ./ordinary_app_records.bend as Leafimport ./ordinary_app_recipe.bend as Treeimport ./ordinary_optional_resource_observation.bend as Leavesimport ./world.bend as Wimport ./system.bend as Sysimport ./transaction.bend as Timport ./ordinary_optional_resource_system.bend as Pimport ./ordinary_resource_field_system.bend as Fieldimport ./check.bend as Kimport ./ordinary_optional_resource_declaration.bend as Dimport ./ordinary_app_observation_data.bend as DTOdef field_owner(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,K.Error,Out>,~clauses:List<&2,Query.Clause<S>>,slot:String,owner:Field.Owner<S,Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>,clauses>) -> Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,runner>> & Records.Fields<S>: match owner: case Field.Owner{registry}:Records.field_registry(~S,~C,~R,~E,~Args,~K.Error,~Out,~runner,slot,clauses,registry)# The same ordinary resource declaration drives registration, observation and metadata.def extracted(~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>>,~Ops:Type -> Type,~Args:Data,~Out:Type,~Value:Data,~declaration:D.Declaration<S,C,R,E,Ops,Value>,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome<K.Error> & Out),~Output:Type,done: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,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,DTO.Product<Rows,Value>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>))> -> Output,failed:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold> -> Output,world:W.World<S,C,R,E>,owners:Owners,debug:Bool,result:Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>> & Records.Fields<S>) -> Output: match result: case (token,fields):done(Build.appended(~S,~W.World<S,C,R,E>,~Owners,~Rows,~observe,~fold,~Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,~Value,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration),~Leaf.observed(~S,~Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>),world,owners,Leaf.Record{token,fields},debug))def defined(~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>>,~Ops:Type -> Type,~Args:Data,~Out:Type,~Value:Data,~declaration:D.Declaration<S,C,R,E,Ops,Value>,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome<K.Error> & Out),~Output:Type,done: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,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,DTO.Product<Rows,Value>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>))> -> Output,failed:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold> -> Output,owners:Owners,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,debug:Bool,slot:String,result:Field.Defined<S,W.World<S,C,R,E>,Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>,Field.clauses(~S,~T.Tx<W.World<S,C,R,E>,E>,~Ops(T.Tx<W.World<S,C,R,E>,E>),D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration))>) -> Output: match result: case Field.Rejected{world}:failed(Build.Registered{world,owners,recipe,debug}) case Field.Defined{world,owner}:extracted(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Out,~Value,~declaration,~body,~Output,done,failed,world,owners,debug,field_owner(~S,~C,~R,~E,~Args,~Out,~P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body),~Field.clauses(~S,~T.Tx<W.World<S,C,R,E>,E>,~Ops(T.Tx<W.World<S,C,R,E>,E>),D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration)),slot,owner))def register(~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>>,~Ops:Type -> Type,~Args:Data,~Out:Type,~Value:Data,~declaration:D.Declaration<S,C,R,E,Ops,Value>,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome<K.Error> & Out),~Output:Type,done: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,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,DTO.Product<Rows,Value>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record<S,Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token<Sys.Registry<S,C,R,E,Args,K.Error,Out,P.runner(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body)>>))> -> Output,failed:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold> -> Output,app:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold>,name:String,slot:String) -> Output: match app: case Build.Registered{world,owners,recipe,debug}:defined(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Out,~Value,~declaration,~body,~Output,done,failed,owners,recipe,debug,slot,P.define(~S,~C,~R,~E,~Ops,~Args,~Out,~Value,~declaration,~body,world,name))