tangled
alpha
login
or
join now
oeiuwq.com
/
fx.go
0
fork
atom
An Algebraic Effect System for Golang.
0
fork
atom
overview
issues
pulls
pipelines
AndContra
oeiuwq.com
10 months ago
17d82bfa
f017f47f
+8
-4
1 changed file
expand all
collapse all
unified
split
fx.go
+8
-4
fx.go
···
144
144
return Then[And[S, Nil], V](left, Const)(e)
145
145
}
146
146
147
147
+
func AndContra[A, B, V any](e Fx[A, V], f func(B) A) Fx[B, V] {
148
148
+
return ContraMap[V](f)(e)
149
149
+
}
150
150
+
147
151
func AndSwap[A, B, V any](e Fx[And[A, B], V]) Fx[And[B, A], V] {
148
152
return Then[And[B, A], V](swap[B, A], Const)(e)
149
153
}
150
154
151
151
-
func AndJoin[A, B, V any](e Fx[A, Fx[B, V]]) Fx[And[A, B], V] {
155
155
+
func AndFlat[A, B, V any](e Fx[A, Fx[B, V]]) Fx[And[A, B], V] {
152
156
return FlatMap(e, identity)
153
157
}
154
158
155
155
-
func AndDisjoin[A, B, V any](e Fx[And[A, B], V]) Fx[A, Fx[B, V]] {
159
159
+
func AndNest[A, B, V any](e Fx[And[A, B], V]) Fx[A, Fx[B, V]] {
156
160
return Pending(func(a A) Fx[A, Fx[B, V]] { return Const[A](ProvideLeft(e, a)) })
157
161
}
158
162
···
161
165
}
162
166
163
167
func ProvideFirstLeft[A, B, C, V any](e Fx[And[And[A, C], B], V], a A) Fx[And[C, B], V] {
164
164
-
return AndJoin(ProvideLeft(AndDisjoin(e), a))
168
168
+
return AndFlat(ProvideLeft(AndNest(e), a))
165
169
}
166
170
167
171
func ProvideFirstRight[A, B, D, V any](e Fx[And[A, And[B, D]], V], b B) Fx[And[A, D], V] {
···
214
218
}
215
219
216
220
func Suspend[A ~func(I) Fx[B, O], B, I, O any](i I) Fx[And[A, B], O] {
217
217
-
return AndJoin(Apply[A](i))
221
221
+
return AndFlat(Apply[A](i))
218
222
}
219
223
220
224
func Handler[A ~func(I) Fx[B, O], B, I, O any](a A) func(Fx[And[A, B], O]) Fx[B, O] {