Understanding the Either.filterOrLeft function and its limitations
Hi, maybe I am doing something wrong with the filter functions. Let's take for instance the Either.filterOrLeft function:
Sometimes I need to do some complex calculation in the predicate part to determine if the Either is valid or not. Issue is that I would like to retrieve part of this calculation in the orLeftWith function because I can then provide a more detailed error message. So ideally, I would like something like:
For the moment, what I do is perform the calculation before the filter and put the result into a tuple, then perform the filter on that tuple, and finally map the tuple back to the original value. For example:
Is this the right way to proceed?
Sometimes I need to do some complex calculation in the predicate part to determine if the Either is valid or not. Issue is that I would like to retrieve part of this calculation in the orLeftWith function because I can then provide a more detailed error message. So ideally, I would like something like:
For the moment, what I do is perform the calculation before the filter and put the result into a tuple, then perform the filter on that tuple, and finally map the tuple back to the original value. For example:
Is this the right way to proceed?
