In Arrow-kt I'd like to create an alias to the bind()
- for a kind of custom lib to use Arrow.
I'd expect the following to work but it doesn't:
suspend fun <F, S> Either<F, S>.bindMy(): S = this.bind()
The method I wanna target is
public interface EffectScope<in R> {
...
public suspend fun <B> Either<R, B>.bind(): B
I guess it doesn't work as I expect because of the EffectScope.
Any idea how I could make it work? Thx
bind
is defined inEffectScope
orRaise
(Arrow 2.0 snapshot) as an extension method overEither<A, B>
.You can go about this in different ways.
EffectScope
interface and define your fold machinery as Arrow does forEffectScope
andEffect
. Unfortunately, until context receivers are available, this is a more heavyweight solution. If you use the 2.0 snapshot, where all this is simpler, you will need to provide similar machinery like Raise and Effect.If you'd like some help with any of this, we hang out in the Kotlin slack #Arrow channel