jeremy
03/17/2019, 1:11 AMBob Glamm
03/18/2019, 2:37 PMfx {
val (rs: ListK<NamedResource>) = service.loadNamedResources()
rs.forEach { r ->
val name: String = r.name
val (ins: InputStream) = !effect { r.resource }
val (contents: ByteArray) = !effect { service.loadContents(ins) }
val (jsonNode: JsonNode) = !effect { service.parseContents(contents) }
val id: String = service.getId(jsonNode).getOrElse { "" }
!effect { <http://LOG.info|LOG.info>("{} -> {}", name, id) }
}
}.unsafeRunSync()
fails with StackOverflowError after processing 98 rs
(there are a total of 443 for it to go through.) Is there some sort of tail recursion method I'm missing?Bob Glamm
03/18/2019, 2:41 PMat kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:114)
at arrow.effects.typeclasses.suspended.FxSyntax$effect$1.invoke(FxSyntax.kt:41)
at arrow.effects.typeclasses.suspended.FxSyntax$effect$1.invoke(FxSyntax.kt:19)
at arrow.effects.extensions.IOConcurrent$async$1.invoke(io.kt:135)
at arrow.effects.extensions.IOConcurrent$async$1.invoke(io.kt:120)
at <http://arrow.effects.IO|arrow.effects.IO>$Companion$async$1.invoke(IO.kt:40)
at <http://arrow.effects.IO|arrow.effects.IO>$Companion$async$1.invoke(IO.kt:26)
at arrow.effects.IORunLoop.loop(IORunLoop.kt:220)
at arrow.effects.IORunLoop.access$loop(IORunLoop.kt:18)
at arrow.effects.IORunLoop$RestartCallback.invoke(IORunLoop.kt:378)
at arrow.effects.IORunLoop$RestartCallback.invoke(IORunLoop.kt:356)
at arrow.effects.internal.Platform$onceOnly$1.invoke(Utils.kt:43)
at arrow.effects.internal.Platform$onceOnly$1.invoke(Utils.kt:18)
at arrow.effects.internal.UtilsKt$asyncContinuation$1.resume(Utils.kt:132)
at arrow.core.Continuation$DefaultImpls.resumeWith(Continuation.kt:12)
at arrow.effects.internal.UtilsKt$asyncContinuation$1.resumeWith(Utils.kt:128)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:45)
thanerian
03/18/2019, 2:43 PMval (ins: InputStream) = ...
and also extract the value from the effect ... !effect{}
thanerian
03/18/2019, 2:43 PMBob Glamm
03/18/2019, 2:47 PMBob Glamm
03/18/2019, 2:51 PMrs.forEach()
? Using val (x: Unit) = IO { <http://LOG.info|LOG.info>("...") }
works, but using !effect { IO { <http://LOG.info|LOG.info>("...") } }
yields StackOverflowError
noiano
03/18/2019, 2:52 PMnoiano
03/18/2019, 2:52 PMnoiano
03/18/2019, 2:52 PMjava.lang.AssertionError: expected: arrow.core.Either$Right<Right(b=GeosetStatus(status=UNKNOWN_GEOSET_STATUS, additionalInfo=Some(GeosetInquiryHttpResponse(errorType=Some(END_DATE_BEFORE_START_DATE), message=Some(wrong dates)))))> but was: arrow.core.Either$Right<Right(b=GeosetStatus(status=UNKNOWN_GEOSET_STATUS, additionalInfo=Some(GeosetInquiryHttpResponse(errorType=Some(END_DATE_BEFORE_START_DATE), message=Some(wrong dates)))))>
noiano
03/18/2019, 2:52 PMnoiano
03/18/2019, 2:52 PMBob Glamm
03/18/2019, 2:53 PMnoiano
03/18/2019, 2:53 PMnoiano
03/18/2019, 2:53 PMnoiano
03/18/2019, 2:54 PMpakoito
03/18/2019, 3:17 PMpakoito
03/18/2019, 3:18 PMassert.AssertEquals
use == and see what happens, maybe the dates are not comparablethanerian
03/18/2019, 3:20 PMthanerian
03/18/2019, 3:20 PMthanerian
03/18/2019, 3:21 PMthanerian
03/18/2019, 6:17 PMraulraja
03/18/2019, 6:29 PMpakoito
03/18/2019, 6:39 PMpakoito
03/18/2019, 6:40 PMpakoito
03/18/2019, 6:40 PMpakoito
03/18/2019, 6:40 PMpakoito
03/18/2019, 6:42 PMpakoito
03/18/2019, 6:42 PM.unsafeRunSync()
should be called once per program/activityBob Glamm
03/18/2019, 6:59 PM.unsafeRunSync()
at the end of a @Test
so that is essentially once per program