-
Notifications
You must be signed in to change notification settings - Fork 15
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
Maybe.Some(null) does not throw and has a different behavior than Maybe.None() #51
Comments
Thanks for reporting this. I'll mark this as a bug for now, until I have time to properly look at the code to assess why it's like it is and whether it's by design or not and whether that design is sensible or not. |
This was definitely by design. Quick update to this: these LDM notes are relevant to this topic. |
I get your point, but does a What do you think ? |
Well it turns out that the changes I'm making for v4 effectively force my hand here. I've never been happy with having
|
Sounds nice! |
@xlecoustillier, since this topic is of interest to you, I'd like your opinion on a related topic, please. What should I do with unions? Taking an extreme case, if I create a My first though was to create yet another breaking change and have unions throw exceptions is given a So I'm tempted to just say that |
Interesting question. So I would go for checking against null each time as you mentioned, or maybe have a property Do you really think it would affect performance ? If yes, and if it's a problem, I personally can live with a default, as, again, it makes no sense and thus should not be used too much, even by mistake. |
…ent in that issue, regarding how null and Option<> compare.
The following was implemented in v4:
Closing as implemented. |
I'm currently testing SuccincT, quite happily so far, but encountered a problem when trying to integrate it in a part of a project I'm working on.
Why is
Maybe<string>.Some(null)
allowed ?var someNull = Maybe<string>.Some(null);
in this case,
someValue.HasValue
returnstrue
andsomeNull.Value
returnsnull
, where I would have expected this to behave the wayMaybe<string>.None()
does (after all, it's seems to be the same thing semantically speaking), or at least to throw.Of course this is not senseless, but in my mind it defeats the objective of Maybe, which is to provide a way of avoiding nulls. That means that if a legacy part of the project passes an unchecked value which turns to be null, Maybe will happily live with it, propagating it without complaining, meaning that I still need to rely on defensive code even in a Maybe enabled codebase.
Is there a reason I don't get behind this behavior ?
If not, which behavior would you recommend / prefer ?
The text was updated successfully, but these errors were encountered: