execution_state_effect.bend

bendvy-ecs-core@0.1.0.3 · 19 lines · 7 definitions

1import Base
2import bendvy-ecs-core@0.1.0.3/execution_effects.bend as E
3
4def Transition(~I:Type,R:Type) -> Type:
5  I -> I & R
6def pure(-I:Type,-R:Type,value:R,invocation:I) -> I & R:
7  (invocation,value)
8def continued(-I:Type,-A:Type,-B:Type,next:A -> I -> I & B,result:I & A) -> I & B:
9  match result:
10    case (invocation,value):next(value)(invocation)
11def bind(-I:Type,-A:Type,-B:Type,action:I -> I & A,next:A -> I -> I & B,invocation:I) -> I & B:
12  continued(I,A,B,next,action(invocation))
13def mapped(-I:Type,-A:Type,-B:Type,next:A -> B,result:I & A) -> I & B:
14  match result:
15    case (invocation,value):(invocation,next(value))
16def map(-I:Type,-A:Type,-B:Type,action:I -> I & A,next:A -> B,invocation:I) -> I & B:
17  mapped(I,A,B,next,action(invocation))
18def dictionary(~I:Type) -> E.Effects<Transition(~I)>:
19  E.Effects{pure(I),bind(I),map(I)}