I was just wondering why the semigroup for Option behaves the way you describe and not returning the non empty Option when combining an empty Option with a non empty one?
That's one of the possible Semigroup instances, which corresponds to the "computation failed" meaning of Option (so if you combine two computations and one of them fails the combination as a whole fails too). There are other possible instances though, see getFirstMonoid, getLastMonoid and getMonoid from the Option module
Hi Giulio, nice post.
I was just wondering why the semigroup for Option behaves the way you describe and not returning the non empty Option when combining an empty Option with a non empty one?
Thanks
That's one of the possible
Semigroup
instances, which corresponds to the "computation failed" meaning ofOption
(so if you combine two computations and one of them fails the combination as a whole fails too). There are other possible instances though, seegetFirstMonoid
,getLastMonoid
andgetMonoid
from the Option moduleI see, thanks for the clarification!