Sum types for value declarations?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 15/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Ambito
- tooling
Direzione di ricerca
This is an open language-design question, not a ready task: first get a maintainer decision on whether variant should apply to value declarations. Read the language reference's sum-type section and the existing variant X : BaseEntity rules. The issue reports that allium check accepts variant on a value and does not validate when effect = nonsense, so those checks are the concrete behaviour to examine. Done means an agreed rule, reference text, and checker tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hey,
I'm writing a spec for a small macOS app and ran into a case where a value would really want to be a sum type. An action is either a key combination, which needs its keys, or a mouse click, which has none:
enum Effect { key_combo | left_click | right_click }
value KeyCombo {
modifiers: Set<KeyModifier>
key: String
}
value Action {
effect: Effect
keys: KeyCombo? -- only for effect = key_combo
}
Right now the "keys only for key_combo" part lives in a comment and a derived is_complete, so the spec can still describe a click that carries keys, or a key combination without them.
Sum types came in with #3 / #4, but only for entities (variant X : BaseEntity). The issue itself talks about "a value is exactly one of A or B", so I wasn't sure whether leaving out values was intended or just didn't come up.
What I noticed with allium check 3.6.1:
variant KeyAction : Actionon avalueis accepted, and an undeclared variant name in the discriminator is reported. So it kind of works already, but the language reference doesn't cover it.keys: KeyCombo when effect = key_comboinside avalueis accepted too, butwhen effect = nonsensepasses as well, so I don't think that's checked.
Are sum types on values something you'd want to support? Or is there a different way you'd model this?
- Lingua principale
- JavaScript
- Stelle
- 538
- Fork
- 29
- Merge medio
- 4g 3h
- PR unite (30g)
- 5
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di juxt/allium
-
language suggestion
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 55/100
-
language suggestion
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
vercel-labs/ui#999 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
swc-project/swc-ai-issues#995 ·
-
[workshop-sim] Repair: Strengthen checkpoints and lock-file prerequisite in Agentic intro (Step 5)Apertafeedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
githubnext/gh-aw-workshop#5973 ·
I maintainer di solito rispondono entro 1 giorno
-
Development server fails with webpack-dev-server 6.1.0Forse già presa @utsxvrai l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rabbitmq/rabbitmq-website#2733 ·
I maintainer di solito rispondono entro 1 giorno