ordinary_component_clear_declaration.bend

bendvy-ecs-core@0.1.0.0 · 19 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.0/world.bend as W
3import bendvy-ecs-core@0.1.0.0/column.bend as Col
4import bendvy-ecs-core@0.1.0.0/ordinary_declaration.bend as Identity
5import bendvy-ecs-core@0.1.0.0/ordinary_component_binding.bend as Binding
6import bendvy-ecs-core@0.1.0.0/ordinary_component_despawn.bend as Clear
7
8# Closed trusted setup declaration; the same clear index supplies execution.
9type Declaration<-S:Data,-Store:Type,-E:Data,-clear:Store -> W.Handle<S> -> Store & List<&2,E>> is Data:
10  Declaration{keys:List<&2,String>}
11def keys(~S:Data,~Store:Type,~E:Data,~clear:Store -> W.Handle<S> -> Store & List<&2,E>,declaration:Declaration<S,Store,E,clear>) -> List<&2,String>:
12  match declaration:
13    case Declaration{keys}:keys
14def leaf(~S:Data,~Store:Type,~Rest:Type,~P:Type,~V:Data,~Token:Data,~take:Store -> Rest & Col.Column<S,P>,~put:Rest -> Col.Column<S,P> -> Store,~view:P -> P & V,~E:Data,~inject:Identity.Declaration<S,P> -> W.Handle<S> -> E,~binding:Binding.Binding<S,Store,Rest,P,V,Token,take,put,view>) -> Declaration<S,Store,E,Clear.leaf(~S,~Store,~Rest,~P,~V,~Token,~take,~put,~view,~E,~inject,~binding)>:
15  Declaration{[Identity.key(~S,~P,Binding.identity(~S,~Store,~Rest,~P,~V,~Token,~take,~put,~view,binding))]}
16def product_clear(~S:Data,~Store:Type,~E:Data,~left:Store -> W.Handle<S> -> Store & List<&2,E>,~right:Store -> W.Handle<S> -> Store & List<&2,E>,store:Store,handle:W.Handle<S>) -> Store & List<&2,E>:
17  Clear.product(~S,~Store,~E,~left,~right,store,handle)
18def product(~S:Data,~Store:Type,~E:Data,~left:Store -> W.Handle<S> -> Store & List<&2,E>,~right:Store -> W.Handle<S> -> Store & List<&2,E>,~leftDeclaration:Declaration<S,Store,E,left>,~rightDeclaration:Declaration<S,Store,E,right>) -> Declaration<S,Store,E,product_clear(~S,~Store,~E,~left,~right)>:
19  Declaration{List.append(&2,String,keys(~S,~Store,~E,~left,leftDeclaration),keys(~S,~Store,~E,~right,rightDeclaration))}