Allow sum types' subtypes to be used as their own types#3
Open
TheLimePixel wants to merge 2 commits intomainfrom
Open
Allow sum types' subtypes to be used as their own types#3TheLimePixel wants to merge 2 commits intomainfrom
TheLimePixel wants to merge 2 commits intomainfrom
Conversation
…may be used on their own
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Over the years, due to develpers' frustration with the enum types in languages such as Rust and Swift, where enum variants cannot be used as their own types, several solutions have been proposed to fix this and with that remove some unnecessary code duplication. One of the proposals which has perhaps garnered the most notoriety is the following Rust proposal. Ultimately, it was rejected due to being a quite a hefty change to the existing language, which could bring unforseen consequences.
Bento, on the other hand, is far from finished and as such I have mae the following PR to incorporate the above proposal together with a few quality-of-life features into the language.
Changes
~and^prefix operators have been added to explicitly do the above conversions much more succinctlyletnow needs to be used when matching to allow the above featureletif-match can now have multiple possible patternsif-matching can now also be used for matching by equality...has been added as a valid pattern within destructuring patterns