Repository navigation
Conversation
Collaborator
Author
|
Closing: the docs are updated for each Rue release with the repo's |
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.
Documents what generic inference does on Rue main, which the pages predate. Rue range:
0.12.0..bb0bef5a(unreleased), generics campaign xch-dev/rue#362.Do not merge before a Rue release
.rue-versionpins0.12.0, the latest release, and CI checks every example with that released CLI. Four of the new examples only compile on main, so therue-examplesjob fails on this PR until the release that has the inference work is out and.rue-versionis bumped (I left it alone, since there's no release to point it at). With therueon my PATH, which reports 0.12.0, these blocks indocs/type-system/generics.mdfail: lambda parameters (the lambda in a pair), accumulators, arguments without values (Never), and union types. Everything passes against a CLI built from main.What changes
docs/type-system/generics.mdgets an Inference section, one short subsection each, each with a compiled example:identity(5)andeither(condition, 5, 6)areInt), unless the expected type keeps the literal (let five: 5 = identity(5)). A type parameter that stands for a whole pair or list keeps the literals inside it (identity((5, "x"))is(5, "x")).accis typed from the seed and what the lambda returns. Pending: this subsection is written for the current behaviour and will be updated when the rule is extended (see below).Never(length(nil),reverse([])is aList<Never>).let r: Result<Int, String> = ok(1)).::<...>is needed: a type parameter only in the return type; branches of aniformatch; generic struct and enum variant initializers (and thatOption::Nonetakes none); a generic function passed as a value.The
mapexample no longer writesfn(value: Int), anddocs/functions.mdsays where a lambda's parameter types come from rather than "the expected type".Pending
The Accumulators subsection's wording is on hold. Its last paragraph says a
nilinside a pair seed ((0, nil)) needs the accumulator typed, which is true onbb0bef5aand is what the in-progress change to Rue is expected to lift. I'll update the subsection when that lands.Checked against the compiler
Every claim and every type in a comment was compiled with a CLI built from Rue main
bb0bef5a, with the inferred type read from an error on a separate binding so that no expected type influenced it. A separate reviewer then checked each sentence against the same binary and found four that were too broad or too narrow, which are corrected here (where literals widen, which type parameters becomeNever, when a generic function passed as a value needs arguments, and the(0, nil)seed).pnpm check:rue-examples --rue <main's rue>for the two pages: 28 examples, all pass.pnpm prettier,pnpm typecheck,pnpm build(no broken links or anchors): pass.Not in this PR
Against main's CLI, four existing examples on other pages fail. They're unrelated to inference and belong to the docs update for the next release:
docs/builtins.mdline 80:keccak256now needshard_fork_2 = trueinRue.tomlor--hard-fork-2.docs/builtins.mdline 116:substris undeclared.docs/builtins.mdline 141:modpownow needshard_fork_2.docs/control-flow.mdline 97: a newmanual_assertwarning, for anifstatement that only raises.Note
Low Risk
Documentation only: two pages, no site code or configuration. The risk is that it describes unreleased behaviour, so it must wait for the Rue release (the example check fails until then), and that the Accumulators subsection is expected to change before that.
mapexample without its annotation.