Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern matching on enums with a list of alternatives #44

Open
skeuchel opened this issue Nov 9, 2023 · 0 comments
Open

Pattern matching on enums with a list of alternatives #44

skeuchel opened this issue Nov 9, 2023 · 0 comments

Comments

@skeuchel
Copy link
Member

skeuchel commented Nov 9, 2023

For pattern matching on unions, we have a version that allows to provide a list of alternatives.

Definition stm_match_union_alt_list {Γ τ} U (s : Stm Γ (ty.union U))
(alts : UnionAlts U Γ τ) (alts_wf : UnionAltsWf alts) : Stm Γ τ :=

This list is checked to be exhaustive by a type-level computation

Definition UnionAltsWf {U Γ τ} (alts : UnionAlts U Γ τ) : Prop :=
Bool.Is_true
(List.forallb
(fun K => option.isSome (findUnionAlt K alts))
(finite.enum (unionk U))).

We currently do not have the same functionality for enums which should be added.

This is useful for replacing the fixed size notations that we use, which sometimes need extension when an enum is extended, e.g. in #43, which is annoying.

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

No branches or pull requests

1 participant