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

Generate COMPLETE pragma for pattern synonyms #26

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

fizruk
Copy link
Owner

@fizruk fizruk commented Aug 23, 2024

The COMPLETE pragma ensures the compiler that a certain combination of patterns in exhaustive.

For example:

data TermSig scope term = AppSig term term | LamSig scope | LetSig term scope
mkPatternSynonyms ''TermSig

will generate

pattern App t1 t2 = Node (AppSig t1 t2)
pattern Lam x body = Node (LamSig (ScopedAST x body))
pattern Let t1 x t2 = Node (LetSig t1 (ScopedAST x t2))
{-# COMPLETE Var, App, Lam, Let #-}

@fizruk fizruk merged commit ba26d91 into main Aug 23, 2024
4 checks passed
@fizruk fizruk deleted the complete-pragma branch August 23, 2024 20:37
@fizruk fizruk mentioned this pull request Oct 27, 2024
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.

1 participant