Make the constraint types read as what they constrain - #72
Merged
Conversation
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.
Closes #70, whose geography half shipped in #71.
Twelve types now implement their representation, so a constrained value reads as the primitive it
constrains and needs no
.value:implements intonDigit,NaturalNumber,Uintand the fiveUintN;implements doubleonProbability;implements StringonAsciiChar,AsciiLettersand
AsciiAlphanumerics, withAsciiAlphanumericandAsciiLetterinheriting it through thenarrowing lattice. Nothing unconstrained can be written into one, and
digit + 1stays a plainint, so arithmetic cannot re-enter the type.Additive, not breaking. The whole workspace analysed clean and all ten suites passed with no
changes outside
minted_constraints. The one way it reaches a consumer is inference:[digit, 7]moves from
List<Object>toList<int>, which is why it is labelledsem-changerather thansem-add. A minor is enough when this releases.Four types opt out, each saying why in its own docs.
Percentageholds15for fifteenpercent, so
percentage * 200would compute3000while reading as fifteen percent of 200.Char,LetterandLettersguarantee characters wherelengthcounts code units, measured at2for one emoji and for one astral letter. The fiveAscii*types escape that because code unitsand characters coincide there, which does leave
AsciiCharaStringwhile its supertypeCharisnot: accepted deliberately, as the price of not letting
lengthlie.Digitswas never in scope, being afinal class extends Iterable<Digit>rather than an extensiontype. Rationale in
APPENDIX.md#constraint-types, and a newtransparent_representation_test.dartcarries the posture as one cross-cutting feature instead of a scenario in twelve files.