id: FR-COMP-008 title: Unified Space-Separated Tuple and Sequence Type Signatures status: implemented priority: must created: 2026-10-22 updated: 2026-10-22 depends_on:
- FR-COMP-003
- FR-COMP-005
verified_by: []
FR-COMP-008 — Unified Space-Separated Tuple and Sequence Type Signatures
Statement
The Ridgun language and ridgunc / stable toolchain SHALL unify the type syntax of argument sequences and tuples so that space-separated types (T1 T2 ... Tn) can be written without redundant commas or outer parentheses in return types, list brackets, and parenthesized tuple types:
- Space-Separated Return Types After
=>/->:
- After
=>or->in afn ::,op ::, or prefixless signature, two or more space-separated type expressionsT1 T2 ... Tn($N \ge 2$) SHALL denote an $N$-element tuple/sequence return type equivalent to(T1, T2, ..., Tn):
fn :: parse header String => Int Int [String String] String
-- Canonical equivalent:
fn :: parse header String => (Int, Int, [(String, String)], String)
- Each component
TiMAY be any valid type expression: a concrete or user-defined type (Int,String,RExpr), a polymorphic type variable (A..Z), a list type ([...]), or a parenthesized type ((...)).
- Space-Separated Tuple Elements Inside List Types (
[T1 T2 ... Tn]):
- Inside list brackets
[...], two or more space-separated (or comma-separated) type expressions[T1 T2 ... Tn]($N \ge 2$) SHALL denote a list of $N$-tuples equivalent to[(T1, T2, ..., Tn)]:
[String String] -- equivalent to [(String, String)]
[Int String Bool] -- equivalent to [(Int, String, Bool)]
[[Int Int] String] -- equivalent to [([(Int, Int)], String)]
- Space-Separated Tuple Elements Inside Parentheses (
(T1 T2 ... Tn)):
- Inside parenthesized type expressions
(...), two or more space-separated (or comma-separated) type expressions(T1 T2 ... Tn)($N \ge 2$) SHALL denote an $N$-tuple equivalent to(T1, T2, ..., Tn), except when the parentheses contain a function arrow=>/->(which denotes a first-class function type(T1 T2 => Ret)):
fn :: fst (A B) => A
fst (a, _) = a
fn :: transform (Int [String String]) => Bool
- Top-Level Input Sequence vs. Nested Tuple Parameter:
- Before
=>in a signature, space-separated typesfn :: compute Int String Int => Booldefine the top-level input sequence (3 positional arguments), whereas parenthesizing a subsequencefn :: compute (Int String) Int => Boolgroups that subsequence into a single nested tuple parameter slot (2 positional arguments, where the first is a 2-tuple).
- 100% Backward Compatibility & Canonical Normalization:
- Both the space-separated syntax (
Int Int [String String] String) and the traditional parenthesized/comma-separated syntax ((Int, Int, [(String, String)], String)) SHALL normalize inparser.rgto the same canonical type string representation"(Int, Int, [(String, String)], String)". - All existing Ridgun code using
(T1, T2)and[(T1, T2)]SHALL remain 100% valid and interchangeable with the space-separated notation.
Rationale
- Conceptual Unity: In Ridgun, a parameter list
Int String Intand a tuple(Int, String, Int)are both typed sequences (seq). RequiringInt String Inton the left of=>while forcing(Int, Int, [(String, String)], String)on the right of=>introduced unnecessary punctuation noise. - Zero Syntactic Ambiguity: Unlike languages of the ML/Haskell family—where juxtaposition in types (
Maybe Int) denotes type constructor application—Ridgun uses explicit parentheses for parameterized types (Tensor(Float, 3, 3)) and brackets for lists ([T]). Furthermore, every type token starts with an uppercase letter (A..Z,Int,String),[, or(, while function and operator words are lowercase. Consequently, space-separated typesT1 T2never collide with type constructors or operator keywords.
Acceptance Criteria
- AC-1 (Space-Separated Return Types): A signature returning multiple space-separated types (including mixed identifiers,
[...]lists, and(...)tuples, such as=> Int Int [String String] String) parses, typechecks, compiles, and runs identically to=> (Int, Int, [(String, String)], String). - AC-2 (List of Tuples
[T1 T2 ...]): A list type with space-separated element types ([String String],[Int String Bool]) parses and typechecks identically to[(String, String)]and[(Int, String, Bool)]. - AC-3 (Parenthesized Space-Separated Tuples
(T1 T2 ...)): Parenthesized tuple types(A B)and(Int [String String] String)work in parameter positions, return types, and nested type positions. - AC-4 (Backward Compatibility): Existing signatures using explicit commas and parentheses (
(Int, Int, [(String, String)], String)) continue to passstable checkandstable testwithout modification.