deferred_command.bend
bendvy-ecs-core@0.1.0.3 · 16 lines · 4 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/trace_facts.bend as Facts
3
4
5type Command<W:Type> is Type:
6 Raw{apply:W -> W}
7 Observed{apply:Facts.State -> W -> W & Facts.State}
8def run(~W:Type,command:Command<W>,world:W,trace:Facts.State) -> W & Facts.State:
9 match command:
10 case Raw{apply}:(apply(world),trace)
11 case Observed{apply}:apply(trace,world)
12def world_only(~W:Type,result:W & Facts.State) -> W:
13 match result:
14 case (world,_):world
15def run_disabled(~W:Type,command:Command<W>,world:W) -> W:
16 world_only(~W,run(~W,command,world,Facts.Off{}))