alpha-2027 · draft-alpha-2027 · tests/language/draft/telescopeView source

Feature contract: binder telescopes#

1. Lexical and grammar rules, including precedence and termination#

(lambda Q1 X1 : A1 . Q2 X2 : A2 . ... Qn Xn : An . BODY), and the same for pi and sigma, with n >= 1. After a binder's ., the three tokens QUANTITY NAME : (a quantity keyword, an identifier, a colon) begin the next binder of the same form; anything else is the body. No term continues with :, so the reading is unambiguous, and a body that is an identifier spelled like a quantity is still a body. Every binder ends with .: a second binder directly after a type is ALPHA-PARSE-UNEXPECTED. There is no new keyword and no new token. The whole telescope is closed by the form's one ).

2. Scope and binding rules, including generated names#

A telescope is the nested binders it abbreviates: (lambda q x : A . r y : B . body) is (lambda q x : A . (lambda r y : B . body)). Each binder scopes over the later binders' types and the body, exactly as nested binders do. Reserved names (zero, Nat, Byte, Bytes, BytesBuilder) are refused as binders (ALPHA-ELAB-RESERVED-NAME). No names are generated.

3. Type and quantity requirements#

The typing and quantity rules are those of the nested binders. In particular a telescope of lambdas is nested lambdas, so a linear or affine outer binder used under a later binder is captured by the inner lambda and refused (ALPHA-QUANTITY-VIOLATION, SPECIFICATION §6): a telescope is not a multi-argument function with joint quantities. A telescope of n lambdas checks only against a type with at least n binders (ALPHA-TYPE-MISMATCH).

4. Effects, totality, and evaluation-order rules#

None of their own: the nested binders' rules apply.

5. Elaboration into existing core or a specifically versioned new core extension#

The parser builds the nested SurfaceLambda, SurfacePi or SurfaceSigma nodes directly (Alpha/Surface/Parser.hs, telescopeBody); elaboration, the kernel and erasure never see a telescope. The core is byte-identical to the nested spelling.

6. Representation and target support, where relevant#

Unchanged: checked interfaces, erasure and every target receive the nested core binders.

7. Error codes and primary/secondary origins#

A telescope under an edition other than alpha-2027 is ALPHA-EDITION-UNSUPPORTED-FORM at the first continued binder's quantity: because the parsed term is the nested one, the gate finds the spelling on the lexemes (Module.draftSyntaxSpans). An inner binder's diagnostics span from its quantity to the end of the body; the outer binder spans the whole form.

8. Formatting and migration rules#

The formatter keeps lexemes, so a telescope stays a telescope and nested binders stay nested. A telescope stays on one line when it fits; otherwise each binder takes its own line at the body's indentation, a comment above a binder or after its . staying where it is. The registered migration binder-telescope (docs/editions/migrations/alpha-2026-to-alpha-2027.txt) rewrites a binder whose whole body is a binder of the same form into one telescope, deleting the inner (, head word and ); a comment between the inner ( and its head leaves that binder nested. alpha migrate proves the rewritten module has the same core.

9. Positive, negative, execution, and edge-case tests#

tests/language/draft/telescope/: lambda, pi and sigma telescopes, mixed quantities, a dependent telescope ((pi erased A : Type 0 . unrestricted value : A . A)), refl between the telescoped and nested spellings, a native run of a three-binder telescope (exit 42), and the capture, missing-dot and arity refusals. debug/lang-contract-check.py checks the edition gate both ways with tests/language/TelescopeUnderAlpha2026.alpha.

10. Compatibility with the old edition, serialized forms, and cache keys#

alpha-2026 refuses the spelling; the nested spelling stays valid in both editions. No core, interface or artifact schema changes; the edition is part of cache identity.

Known discrepancies and limits#

  • Only binders of one form chain: a pi inside a lambda body stays a separate form.
  • The self-hosted front end (packages/compiler) parses telescopes under alpha-2027 (scripts/proofs/alpha-dependent-telescope-parser.sh), and its own closure is written with them.