An Algebraic Effect System for Golang.

Rename to Then

+6 -6
+6 -6
fx.go
··· 52 52 } 53 53 54 54 // Continue an effect by transforming its immediate value into another effect. 55 - func Cont[T, U, S, V any](cmap func(T) S, fmap func(V) Fx[T, U]) func(Fx[S, V]) Fx[T, U] { 55 + func Then[T, U, S, V any](cmap func(T) S, fmap func(V) Fx[T, U]) func(Fx[S, V]) Fx[T, U] { 56 56 return func(e Fx[S, V]) Fx[T, U] { 57 57 if e.stp != nil { 58 58 return Stop(func() Fx[T, U] { 59 - return Cont(cmap, fmap)(e.stp()) 59 + return Then(cmap, fmap)(e.stp()) 60 60 }) 61 61 } 62 62 if e.imm != nil { 63 63 return fmap(e.imm()) 64 64 } 65 - return Pending(func(t T) Fx[T, U] { return Cont(cmap, fmap)(e.sus(cmap(t))) }) 65 + return Pending(func(t T) Fx[T, U] { return Then(cmap, fmap)(e.sus(cmap(t))) }) 66 66 } 67 67 } 68 68 ··· 123 123 } 124 124 125 125 func FlatCont[N, A, U, B, V any](amap func(N) A, bmap func(N) B, fmap func(U) Fx[B, V]) func(Fx[A, U]) Fx[N, V] { 126 - return Cont(amap, func(u U) Fx[N, V] { return Cont(bmap, Const[N, V])(fmap(u)) }) 126 + return Then(amap, func(u U) Fx[N, V] { return Then(bmap, Const[N, V])(fmap(u)) }) 127 127 } 128 128 129 129 func AndNil[S, V any](e Fx[S, V]) Fx[And[S, Nil], V] { 130 - return Cont[And[S, Nil], V](left, Const)(e) 130 + return Then[And[S, Nil], V](left, Const)(e) 131 131 } 132 132 133 133 func AndSwap[A, B, V any](e Fx[And[A, B], V]) Fx[And[B, A], V] { 134 - return Cont[And[B, A], V](swap[B, A], Const)(e) 134 + return Then[And[B, A], V](swap[B, A], Const)(e) 135 135 } 136 136 137 137 func AndJoin[A, B, V any](e Fx[A, Fx[B, V]]) Fx[And[A, B], V] {