ordinary_app_recipe.bend
bendvy-ecs-core@0.1.0.0 · 12 lines · 0 definitions
1import Base
2import bendvy-ecs-core@0.1.0.0/ordinary_app_observation_data.bend as DTO
3type Recipe<World:Type,Rows:Data,-observe:World -> World & DTO.Observation<Rows>> is Type:
4 Recipe{}
5def observation_right(~World:Type,~L:Data,~R:Data,left:L,leftText:List<&2,String>,result:World & DTO.Observation<R>) -> World & DTO.Observation<DTO.Product<L,R>>:
6 match result:
7 case (world,DTO.Observation{right,rightText}):(world,DTO.Observation{DTO.Product{left,right},List.append(&2,String,leftText,rightText)})
8def observation_left(~World:Type,~L:Data,~R:Data,~right:World -> World & DTO.Observation<R>,result:World & DTO.Observation<L>) -> World & DTO.Observation<DTO.Product<L,R>>:
9 match result:
10 case (world,DTO.Observation{value,text}):observation_right(~World,~L,~R,value,text,right(world))
11def observe_pair(~World:Type,~L:Data,~R:Data,~left:World -> World & DTO.Observation<L>,~right:World -> World & DTO.Observation<R>,world:World) -> World & DTO.Observation<DTO.Product<L,R>>:
12 observation_left(~World,~L,~R,~right,left(world))