either make something that works for Applicative s...
# arrow
p
either make something that works for Applicative so it works for both and any other implementation; or make 2 functions, one for either and the other for validated
g
Thanks @pakoito, since
bimap
is common for both
Either
and
Validated
, my intention is to write one function for it. How can I achieve this with
Applicative
?
p
Bifunctor then
g
Hmm, let me explore
This is what I did ```
Copy code
fun <S> User.upsert(BF: Bifunctor<S>, result: Kind2<S, Nel<ValidationError>, Unit>) =
            BF.run {
                result.bimap(toLeft(), toRight())
            }
Calling it this way:
user.upsert(Either.bifunctor(), result)
But there is no
bifunctor()
for
Validated
😞
@pakoito
r
BiFunctor should be possible in Validated, if you want to contribute it to the validated instances we could include it in the next release
should look fairly similar to the Either instance
g
Sure, I shall do that 🙂
@raulraja Just FYI, My PR for Validated Bifunctor got merged last Friday
👏 1
r
congrats!
and thank you!
🙂 1