fun <A> Validated<NonEmptyList<YourType>, A>.toIO(): IO<A> {
return when (this) {
is Valid -> this.a.just()
is Invalid -> YourErrorType(this.e).raiseError()
}
}
👏🏼 1
🔝 2
a
antonicg
05/08/2020, 6:50 AM
right, or also you can call
toEither()
and then
toIO()
, but I was asking because, shouldn’t it be one? I am in to contribute if people think that makes sense for the library
p
pakoito
05/08/2020, 12:03 PM
Not for Validated in particular. Either makes sense for the suspend functions that return Either for errors are frequent.