-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Either combine only use Semigroup[B]
#1321
Comments
so, it originally worked this way, I would say with If you want a implicit val leftSg: Semigroup[A] = new Semigroup[A] {
def combine(a: A, b: A): A = a
} But if you want to use I have used either for approximation Monoids where there is also an exact algorithm. For small sizes, I use the But I still think if you want to only keep the left, you should set up a semigroup to do so. |
If we wanted to go this way we could provide something like: object ThrowableSemigroup extends Semigroup[Throwable] {
def combine(x: Throwable, y: Throwable): Throwable = x
} That way this change would be source compatible in almost all cases. |
I'm not sure about this. I feel that It also feels strange because then it becomes inconsistent with |
@johnynek at this point it seems like it would be pretty disruptive to make this change. Are you okay with closing this issue out? I'm not sure about your specific use-case, but I think that the support for |
I am not arguing for accumulating errors. For that I agree Validated works. As I mentioned, this is for using Either as a generic sum, which it is. But I guess if we want a generic sum type (like the example I mentioned where we have two representations that we can convert from one to the other but not vice versa) we are on our own. We should document: Either is exclusively for monadic error accumulation in cats and any other usage of Either is likely to have confusing outcomes. If you need a generic sum, that does not have monadic error semantics (Either this or that) you should make a new type because you may get confusing results. |
note
combine(a, b) = a
is a semigroup. We are basically forcing this "left-semigroup" on the left side.I don't think this is a great idea at all. I would rather have:
The text was updated successfully, but these errors were encountered: