Hello everyone, I bumped into something while I wa...
# arrow
g
Hello everyone, I bumped into something while I was trying to do some error accumulation with the new functions from
1.2.0
. I’m using a type alias for a
NonEmptyList
that looks like this
typealias ApplicationErrors = NonEmptyList<ApplicationError>
, however when used together with the
either
DSL and
parZipOrAccumulate
the code fails to compile.
suspend fun getDetails(param: Param): Either<ApplicationErrors, User> =
either {
parZipOrAccumulate(
{ serviceOne.getUser(param).bind() },
{ serviceTwo.getUserDetails(param).bind() },
{ serviceThree.getUserPermissions(param).bind() }
) { user, details, permissions ->
// do something with the user
}
}
If I just change the return type from
Either<ApplicationErrors, User>
to
Either<Nel<ApplicationError>, User>
everything works as expected. I wasn’t expecting this to happen, any idea why? Thank you!
d
parZipOrAccumulate gathers the errors in a nel...
g
yes, I know, but
ApplicationErrors
is a typealias for a
NonEmptyList<ApplicationError>
d
Oh... sorry, that's VERY strange, usually typealiases don't really exist at all in compiled code. Maybe try using Intellij's decompiler to Java and compare what it gives with and without the typealias?
s
If I just change the return type from
Either<ApplicationErrors, User>
to
Either<Nel<ApplicationError>, User>
everything works as expected.
Wow, that is very strange 🤯 Did you ever find out what was happening here? What Kotlin version are you on? I was out in August but Arrow 1.2.1 with Kotlin 1.9.x should get released this week