1 import Base 2 import ./execution_effects.bend as E 3 4 def Transition(~I:Type,R:Type) -> Type: 5 I -> I & R 6 def pure(-I:Type,-R:Type,value:R,invocation:I) -> I & R: 7 (invocation,value) 8 def 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) 11 def 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)) 13 def 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)) 16 def 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)) 18 def dictionary(~I:Type) -> E.Effects: 19 E.Effects{pure(I),bind(I),map(I)}