Hareendran
01/10/2022, 2:59 PMEither
fun getConfigVersion(configId: ConfigId, versionId: ConfigVersionId): Either<DomainError, PIConfigVersion> {
val configVersion = configVersionRepository.findByPiConfigModel_ProfileIdAndVersion(configId.id, versionId.id)
return configVersion?.right() ?: NoVersionsFound("No ConfigVersion found for Config ${configId.id} and version ${versionId.id}").left()
}
Ties
01/10/2022, 3:01 PMHareendran
01/10/2022, 3:01 PMeither.eager<DomainError, List<Policy>> {
val piConfigVersion = getConfigVersion(evRequest.configId, evRequest.versionId).bind()
}
Hareendran
01/10/2022, 3:02 PMraulraja
01/10/2022, 3:31 PMHareendran
01/10/2022, 3:41 PMHareendran
01/10/2022, 3:42 PMList<Either<DomainError, Policy>>
Hareendran
01/10/2022, 3:42 PMEither<DomainError, List< Policy>>>
Hareendran
01/10/2022, 3:43 PMresults.sequence(Either.applicative()).fix().map { it.fix() }) {
is Either.Left -> throw RuntimeException("There is an Error while saving incidents" + result.a)
is Either.Right -> result.b
}
Hareendran
01/10/2022, 3:43 PMraulraja
01/10/2022, 3:51 PMraulraja
01/10/2022, 3:51 PMraulraja
01/10/2022, 3:53 PMtraverse
Hareendran
01/10/2022, 4:07 PMList<Either<DomainError, Policy>> to
Either<DomainError, List<Policy>> to
raulraja
01/10/2022, 4:14 PMfun <E, A> Iterable<Either<E, A».sequenceEither(): Either<E, List<A»
raulraja
01/10/2022, 4:14 PMsequenceEither
in the collectionraulraja
01/10/2022, 4:16 PMtraverseEither
instead.raulraja
01/10/2022, 4:17 PMsequenceEither
https://arrow-kt.io/docs/apidocs/arrow-core/arrow.core/sequence-either.htmlHareendran
01/10/2022, 4:20 PM