Replies: 1 comment
-
Actually managed to get it working with using custom combine function in both mapOrAccumulate and zipOrAccumualte combine = { e1, e2 -> e1 + e2 } But i believe the default behaviour is just confusing and easy to make a mistake |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using arrow-core 1.2.0
I think I'm missing some kind of flatMapOrAcculate function.
Consider the example from the documentation
Book class on creation returns the following: Either<NonEmptyList, Book> and the Author invoke method: Either<EmptyAuthorName, Author>.
Now imagine that Author class also returns a list of errors because there are multiple validations, so the return type is Either<Nel, Author>
it acutally makes the compiler not complaing but the behavior is different - now i only receive the errors from the first Author from the list, disregarding the remaining authors and the book validations. Sample code:
after creating a book: Book("", listOf("", "x")) i'd expect to receive EmptyTitle, EmptyAuthorName and InvalidAuthorName twice yet all i get is Either.Left(NonEmptyList(EmptyAuthorName@5b80350b, InvalidAuthorName(name=)))
What am I missing here? how to flatMap this structure?
Beta Was this translation helpful? Give feedback.
All reactions