recovery_journal.bend

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

1import Base
2# Engine seam. Ordinary gameplay receives only canonical operation grants.
3# Every action is invoked on both outcomes; no closure-held owner is discarded.
4def Action(~State:Type,~Recovery:Type) -> Type:
5  Bool -> State -> Recovery -> State & Recovery
6def applied(~State:Type,~Recovery:Type,next:State -> Recovery -> State & Recovery,result:State & Recovery) -> State & Recovery:
7  match result:
8    case (state,recovery):next(state,recovery)
9def finish(~State:Type,~Recovery:Type,journal:List<Action(~State,~Recovery)>,+success:Bool,state:State,recovery:Recovery) -> State & Recovery:
10  match journal:
11    case []:(state,recovery)
12    case action <> rest:applied(~State,~Recovery,s => r => finish(~State,~Recovery,rest,success,s,r),action(success,state,recovery))