Closed Insomniak47 closed 5 years ago
I think .asmaybe solves the issue when you're unsure. Given that the ctor throws anyways there's really no difference is there?
Yea the convo was about whether an implicit cast should be available when the ctor might throw. I'm all for ctor exceptions for bad args, but IIRC we decided that an implicit cast should only be available for cases where it wouldn't throw. I'm okay with going against it, just want to be sure we don't make that decision without considering this other principle we had talked about before.
Yeah I think I remember that conversation. I think now that there is an alternative in the cases where there's a possibility of null (AsMaybe) the ergonomic tradeoff vs the weirdness of the implicit cast throwing makes more sense. Given that that's only a risk at the boundaries of the otherwise "safe" system and the fact that it makes the error apparent immediately I think that the tradeoff might be worth it now.
Really I just want to avoid typing:
return new Maybe<Thing>(new Thing(params...));
Yea that's fair
This seems like a bit of a no brainer. The ability to remove a lot of the new Maybe() is a blessing. Only thing that would be nice would be a nicer way to give None without the full qualification but all the solutions I've thought of so far are exactly as verbose.