pakoito
10/06/2020, 4:47 PMeither { }
is already a monad transformer because it allows suspend functions inside š±julian
10/06/2020, 5:49 PMpakoito
10/06/2020, 5:51 PMIO<Either<E, A>>
is suspend fun bla(): Either<E, A>
. So itās nested and not immediately composablepakoito
10/06/2020, 5:52 PMbla().flatMap {
bla() // cannot call suspend functions inside flatMap
}
pakoito
10/06/2020, 5:52 PMeither
declarationpakoito
10/06/2020, 5:52 PMEitherT<suspend, E, A>
pakoito
10/06/2020, 5:53 PMeither {
bla().bind()
bla().bind()
}
julian
10/09/2020, 9:50 PMEitherT<suspend, E, A>
to illustrate, or you meant it literally?julian
10/09/2020, 9:51 PMpakoito
10/09/2020, 9:52 PMpakoito
10/09/2020, 9:53 PMAlso, can you explain a bit what you mean by ānot immediately composableā?
bla().flatMap {
bla() // cannot call suspend functions inside flatMap
}
thatās one examplepakoito
10/09/2020, 9:54 PMsuspend fun somethig() {
val a: Either<Int, Int> = bla()
val b: Either<Int, Int> = bla()
}
you donāt have a function to easily sequence one after another and shortcircuit on failure, if you prefer to see it this waypakoito
10/09/2020, 9:55 PMpakoito
10/09/2020, 9:56 PMpakoito
10/09/2020, 9:57 PMjulian
10/12/2020, 3:34 AMjulian
10/12/2020, 5:40 PMunless you make flatMap support suspend inside, either directly accepting a suspend lambda or via inline (which is a bad hack IMO)Is this referring to making
flatMap
inline?