Hiosdra
01/29/2020, 8:38 PMfun validatePhotoMatch(login: Login, photo: ByteArray): IO<Error, Unit> =
IO.monad<Error>().fx.monad {
val user = !userService.getUserByLogin(login)
val modelVectors = !extractFaceVectors(user)
val unknownVectors = !recognitionService.calculatePhoto(photo)
val resultDto = !recognitionService.calculateDifference(unknownVectors, modelVectors)
!failureOrUnit(resultDto.result)
}.fix()
I cannot make second line: as IO.fx {
. Idea cannot decide if it should be:
IO.Companion.fx(c: suspend IOSyntax<E>.() -> A): IO<E, A>
Or:
IO.Companion.fx(c: suspend ConcurrentSyntax<IOPartialOf<Nothing>>.() -> A): IO<Nothing, A>
Is it some kind of bug with new IO being BIO? Or I do something bad? Type inference should see that there is Error on left side, not Nothing. (I use my own Error class in ADT)
Every method used in for-comprehension is returning IO<Error, x>
Arrow Gradle deps are:
val arrowVersion = "0.11.0-SNAPSHOT"
implementation("io.arrow-kt:arrow-fx:$arrowVersion")
implementation("io.arrow-kt:arrow-fx-reactor:$arrowVersion")
implementation("io.arrow-kt:arrow-mtl:$arrowVersion")
implementation("io.arrow-kt:arrow-mtl-data:$arrowVersion")
implementation("io.arrow-kt:arrow-syntax:$arrowVersion")
implementation("io.arrow-kt:arrow-integration-retrofit-adapter:$arrowVersion")
kapt("io.arrow-kt:arrow-meta:$arrowVersion")
And second:
Maybe add function Either<E, A>.toIO<E, A>()
? There are already functions that map left side of Either to “below” side of IO, but I couldn’t see any mapping Either left to IO left. In BIO it would be very easy. I have written it for my own purpose and can push pull-request to 0.11.0 branch ;)Attila Domokos
01/29/2020, 8:53 PMHiosdra
01/29/2020, 9:09 PM