Skip to content

Use destructuring syntax for process record/tuple inputs#6912

Merged
bentsherman merged 2 commits intomasterfrom
adr/record-syntax-unification
Mar 26, 2026
Merged

Use destructuring syntax for process record/tuple inputs#6912
bentsherman merged 2 commits intomasterfrom
adr/record-syntax-unification

Conversation

@pditommaso
Copy link
Copy Markdown
Member

@pditommaso pditommaso commented Mar 12, 2026

Summary

  • Proposes using the record() function-call notation uniformly for both process inputs and outputs
  • Replaces the asymmetric Record { ... } block syntax currently used only in input declarations
  • Aligns with existing assignment (=) and type annotation (: Type) patterns already present in process I/O

Current (asymmetric):

input:
sample: Record {         // block syntax, unique to inputs
    id: String
    fastq_1: Path
}

output:
record(id: sample.id, html: file('*.html'))   // function call

Proposed (uniform):

input:
sample: Sample = record(id: String, fastq_1: Path)

output:
result: OtherType = record(id: sample.id, html: file('*.html'))

Test plan

  • Review ADR content for accuracy and completeness
  • Discuss with team whether this direction aligns with typed syntax roadmap

🤖 Generated with Claude Code

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 12, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 1e47466
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69c5535ae6b7a80008d97858

Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
@bentsherman
Copy link
Copy Markdown
Member

Great discussion overall. I would be keen to incorporate this somehow into the record type ADR, since we did discuss some of these options throughout the process but I didn't include them as alternatives in the original ADR

Would be good to document these alternatives so that we have the clear rationale for the final syntax

@bentsherman

This comment was marked as outdated.

Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
@bentsherman bentsherman changed the title ADR: Unified record syntax for process I/O ADR: Unified record syntax for process inputs/outputs Mar 12, 2026
Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
Comment thread adr/20260312-record-syntax-unification.md Outdated
@pditommaso
Copy link
Copy Markdown
Member Author

Updated ADR: Unified constructor notation for record() and tuple()

Key changes in this update:

  1. Broadened scope from record-only to all structured types. The proposal now establishes name = constructor(...) as a uniform notation that applies to both record() and tuple(), not just records.

  2. Three-tier notation for both constructors:

    tuple(id, file('*.bam'))                          // bare
    out = tuple(id, file('*.bam'))                    // assignment
    out: Tuple<String,Path> = tuple(id, file('*.bam'))  // typed assignment

    Same pattern for record() — bare, assignment, typed assignment.

  3. Migration path from classic DSL2 through tuples to records:

    tuple val(id), path(fastq)             // classic DSL2
    in = tuple(id: String, fastq: Path)    // typed — uniform notation
    in = record(id: String, fastq: Path)   // record — just change the keyword
  4. Tuple input with inline named typesin = tuple(id: String, fastq: Path) — gives tuples named components while preserving positional semantics, mirroring record input notation exactly.

  5. Coexistence example showing both tuple() and record() in the same pipeline with identical notation shape.

The core value: users learn one pattern and apply it everywhere. The only choice is positional (tuple) vs named (record).

@bentsherman bentsherman force-pushed the adr/record-syntax-unification branch from 2c51e4f to 7e2441d Compare March 24, 2026 22:06
@bentsherman bentsherman requested review from a team as code owners March 24, 2026 22:06
@bentsherman bentsherman changed the title ADR: Unified record syntax for process inputs/outputs Use destructuring syntax for process record/tuple inputs Mar 24, 2026
Copy link
Copy Markdown
Collaborator

@christopher-hakkaart christopher-hakkaart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made two comments: one typo and one language suggestion. Otherwise the docs look good.

Comment thread docs/process-typed.md Outdated
Comment thread docs/process-typed.md Outdated
@bentsherman bentsherman added this to the 26.04 milestone Mar 25, 2026
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@bentsherman bentsherman force-pushed the adr/record-syntax-unification branch from c7bb702 to c2f631f Compare March 26, 2026 14:29
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@bentsherman bentsherman merged commit 028e4cc into master Mar 26, 2026
22 of 24 checks passed
@bentsherman bentsherman deleted the adr/record-syntax-unification branch March 26, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants