execution_state_effect.bend source
execution_state_effect.bend on the hub · documented module
import Baseimport ./execution_effects.bend as Edef Transition(~I:Type,R:Type) -> Type: I -> I & Rdef pure(-I:Type,-R:Type,value:R,invocation:I) -> I & R: (invocation,value)def continued(-I:Type,-A:Type,-B:Type,next:A -> I -> I & B,result:I & A) -> I & B: match result: case (invocation,value):next(value)(invocation)def bind(-I:Type,-A:Type,-B:Type,action:I -> I & A,next:A -> I -> I & B,invocation:I) -> I & B: continued(I,A,B,next,action(invocation))def mapped(-I:Type,-A:Type,-B:Type,next:A -> B,result:I & A) -> I & B: match result: case (invocation,value):(invocation,next(value))def map(-I:Type,-A:Type,-B:Type,action:I -> I & A,next:A -> B,invocation:I) -> I & B: mapped(I,A,B,next,action(invocation))def dictionary(~I:Type) -> E.Effects<Transition(~I)>: E.Effects{pure(I),bind(I),map(I)}