DavidArno / SuccincT

Discriminated unions, pattern matching and partial applications for C#
MIT License
267 stars 15 forks source link

Adds HasValue method to unions #53

Closed kgreen24 closed 6 years ago

kgreen24 commented 6 years ago

Add a method HasValue to unions. This allows for imperative checking that the union's selected case is of a certain type without having to reference Case1, Case2, etc... Also avoids using exceptions for control flow.

DavidArno commented 6 years ago

That all looks really good. Thanks for this addition, Kevin.

DavidArno commented 6 years ago

In updating the wiki for this, I feel it better to rename this method to HasValueOf<T>, as it just seems to fit the naming conventions of SuccincT better (very subjective). Do you have any strong objections to this? If not, I'll update the code and go with that name.

kgreen24 commented 6 years ago

No strong opinion, the motivation on my end for HasValue was that Option also has a HasValue method, so the naming may be more familiar.