Spike: model Option, Either and Result on C# unions and closed hierarchies

Aperta
#1,034 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Read the issue's measurements and compatibility checklist, then inspect the current Option<T> struct and its tests alongside the trait prototype branch for #862. Build a time-boxed prototype on that branch and compare allocations, pattern matching, public surface, compatibility, and dependent issues with today's struct; document the results here and recommend whether 4.0.0 should adopt the union shape.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

experimental to discuss

Time-boxed prototype that decides the shape of the 4.0.0 type redesign. Decided at the 4.0.0 grooming on 29 Oct 2026; part of the umbrella issue for the Closed Hierarchy Update.

Question

What do Option<T>, Either<L, R> and Result<T> become on .NET 11 / C# 15, now that the language has union types and closed hierarchies?

Deliverable

One branch (not for merging) that implements Option<T> in the candidate shape, plus Either or Result if the shape raises questions a single type cannot answer. A write-up on this issue that compares it with today's struct, measured on:

  • Allocations and size: does the union shape stay allocation-free, what is sizeof, does it still fit in a register pair.
  • Pattern matching: exhaustiveness in switch expressions, whether [var value] list patterns and is Some style checks survive, what the error message looks like for a missing case.
  • Public surface: what happens to the implicit conversion from T, Option<T>.None, the Match/Select/SelectMany members, and the JSON converter and xunit serializer.
  • Binary and source compatibility: which 3.8.0 call sites break, so the upgrade chapter can list them.
  • Dependents: what the shape means for the issues that wait on it: #809 (constructors), #760 (collection expressions), #868 (UpCast/DownCast extensions), #864 (Task as a monad), #802 (Validation applicative).
Time box

One week of effort. If the union shape is not clearly better than the current struct on the measurements above, 4.0.0 keeps the structs and the "closed hierarchy" is expressed only where it is free (e.g. closed on the union-like hierarchies the generator used to produce, exhaustiveness via the analyzer).

Runs on the same branch as the trait prototype of #862, because both answer the interface-and-boxing question.

Lingua principale
C#
Stelle
55
Fork
6
Merge medio
23h 51m
PR unite (30g)
89

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di polyadic/funcky

Tutte le issue di polyadic/funcky

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.