Hi guys I need to migrate this to arrow 1.0: ```Va...
# arrow
a
Hi guys I need to migrate this to arrow 1.0:
Copy code
Validated.applicative(validationSemigroup).tupled(Valid("foo"), Valid("bar")).fix()
where:
Copy code
val validationSemigroup: Semigroup<List<WebError>> = object : Semigroup<List<WebError>> {
    override fun List<WebError>.combine(b: List<WebError>): List<WebError> =
        Stream.concat(stream(), b.stream()).toList()
}
I have tried to do it with zip
like:
Copy code
Valid("foo").zip(Valid("bar"), ::Pair)
s
Copy code
val validationSemigroup: Semigroup<List<WebError>> = object : Semigroup<List<WebError>> {
    override fun List<WebError>.combine(b: List<WebError>): List<WebError> =
        this + b
}

Valid("foo").zip(validationSemigroup, Valid("bar"), ::Pair)
a
but zip method compains
s
There is also no need to use
Stream.concat
inside
Semigroup
you can just use
List.plus
from Kotlin.
If you’re working with
ValidatedNel
you can omit the
semigroup
parameter to
zip
.
Which is probably more interesting for you too, since having
List
inside
Invalid
means it can also contain an empty list of errors, which typically isn’t possible.
NonEmptyList
is just like
List
but has a minimum size of
1
instead of
0
. It has special support for
Validated
in for example
zip
.
a
That last part makes total sense
and thank you for the qucik respone Simon. I am trying that
Also forces web validations users to always return a list with at least one Weberror when it exist
💯 2
great