execution_save_gate.bend

bendvy-ecs-core@0.1.0.3 · 15 lines · 3 definitions

1import Base
2
3type Outcome<-Value:Data,-Error:Data> is Data:
4  Saved{value:Value}
5  RefusedPending{}
6  Refused{error:Error}
7
8# Framework boundary. The ordinary adapter supplies the closed owner inventory,
9# not deferred history or a caller's estimate of outstanding work.
10def checked(~Actual:Type,~Value:Data,~Error:Data,~project:Actual -> Actual & Outcome<Value,Error>,result:Actual & Bool) -> Actual & Outcome<Value,Error>:
11  match result:
12    case (actual,True{}):(actual,RefusedPending{})
13    case (actual,False{}):project(actual)
14def save(~Actual:Type,~Value:Data,~Error:Data,~pending:Actual -> Actual & Bool,~project:Actual -> Actual & Outcome<Value,Error>,actual:Actual) -> Actual & Outcome<Value,Error>:
15  checked(~Actual,~Value,~Error,~project,pending(actual))