pakoito
09/29/2019, 3:53 PMio.map { ei -> ei.map { l -> l.map { b -> toC(b) } } }Joram Visser
09/29/2019, 7:48 PMIO<Either<A, List<Either<A, C>>>>, instead of IO<Either<A, List<C>>. 😵 Still having a hard time going from the first to the latter.pakoito
09/29/2019, 9:00 PMtoC returns Either then?Joram Visser
09/29/2019, 9:03 PMEither<A, C>. Also see second function in the initial snippet.pakoito
09/29/2019, 9:26 PMei.flatMap { l -> l.map { b -> toC(b) }.sequence(Either.applicative<A>()) }Yeray Cabello
09/30/2019, 10:52 AMflatMap is life.Joram Visser
09/30/2019, 7:48 PMpakoito
09/30/2019, 8:09 PMpakoito
09/30/2019, 8:09 PMpakoito
09/30/2019, 8:10 PMIO<Either<String, List<A>> and you want to apply a suspend function to itpakoito
09/30/2019, 8:10 PMpakoito
09/30/2019, 8:12 PMIO<Either<String, List<IO<B>>> and then into
IO<Either<String, IO<List<B>>>
And then
IO<IO<Either<String, List<A>>>
and finally you can flatten thatpakoito
09/30/2019, 8:15 PMIO.fx {
val eit: Either<String, List<A>> = io.bind()
val eit2: Either<String, IO<List<B>>> =
ei.map { l -> l.map { b -> toC(b) }.sequence(IO.applicative()) }
val eit3: Either<String, List<B>> =
eit2.sequence(IO.applicative()).bind()
}pakoito
09/30/2019, 8:16 PM.sequence(IO.applicative())Joram Visser
09/30/2019, 8:18 PMfun Candidate.toViewModel()) function. Because maybe it doesn’t need to be complicated. 😅
But will try with .sequence(IO.applicative()) now and see if I can get past this not an easy problem. 🙂Joram Visser
09/30/2019, 8:31 PMtoC(b) in the snippet you posted can’t be invoked without a coroutine scope.
IO.fx { !effect { toC(b) } } This does make it possible to invoke toC(b). But then the .sequence(IO.applicative()) isn’t happy. 😵pakoito
09/30/2019, 8:50 PMpakoito
09/30/2019, 8:50 PMl.map { b -> IO.effect { toC(b) } }pakoito
09/30/2019, 8:50 PMpakoito
09/30/2019, 8:51 PMpakoito
09/30/2019, 8:51 PMJoram Visser
10/01/2019, 5:43 AMpakoito
10/04/2019, 5:47 PM.fix() after sequence inside the mappakoito
10/04/2019, 5:48 PMmap { it.fix() }pakoito
10/04/2019, 5:48 PMpakoito
10/04/2019, 5:48 PMpakoito
10/04/2019, 5:48 PMpakoito
10/04/2019, 5:48 PMpakoito
10/04/2019, 5:49 PMfix on itpakoito
10/04/2019, 5:49 PMraulraja
10/04/2019, 6:41 PMJoram Visser
10/04/2019, 7:16 PMIO.fx { !effect { ... } } and IO.effect { ... }?
Is there another way to go from Kind<ForListK, C> to List<C> than it.fix() as List<C> (without casting)?pakoito
10/04/2019, 11:17 PMWhat is the difference betweenThe first one goes through extra hoops to get the same resultandIO.fx { !effect { ... } }?IO.effect { ... }
pakoito
10/04/2019, 11:17 PMMaybe it can use some minor revisionsI’m sure you can get away with a couple fewer fixes. Still, you won the game of type tetris 😄
pakoito
10/04/2019, 11:18 PMit.fix() as List<C> looks incorrect, is my only concernpakoito
10/04/2019, 11:18 PMit here?pakoito
10/04/2019, 11:19 PMeit445.map { it.flatten() } is just flatMap { it }, hence the name 😄Joram Visser
10/05/2019, 7:18 AMit in it.fix() as List<C> is a `Kind<ForListK, C>. To me, that looked also not correct. 😅 That is why I asked the question if there is another way to do this transformation.Joram Visser
10/05/2019, 7:24 AMStill, you won the game of type tetris 😄I slept like a rock! 🥇😴
pakoito
10/05/2019, 10:35 AMit.value() instead of it.fix().value IIRCpakoito
10/05/2019, 10:36 AMpakoito
10/05/2019, 10:36 AMpakoito
10/05/2019, 10:36 AMpakoito
10/05/2019, 10:36 AMval a: List<C> = it.fix()
aJoram Visser
10/05/2019, 11:18 AM