ddc-source-tetra- Disciplined Disciple Compiler source language.

Safe HaskellNone



Desugar match expressions to case expressions.

In a match expression if matching fails in one block of guards then we skip to the next block. This introduces join point at the start of every block of guards execpt the first one, which we need to flatten out when converting to plain case expressions.

We also merge multiple clauses for the same function into a single one while we're here.



type S = State (Text, Int) Source #

State holding a variable name prefix and counter to create fresh variable names.

evalState :: Text -> S a -> a Source #

Evaluate a desguaring computation, using the given prefix for freshly introduced variables.

newVar :: Text -> S (Bind, Bound) Source #

Allocate a new named variable, yielding its associated bind and bound.

desugarModule :: Module Source -> S (Module Source) Source #

Desugar match expressions to case expressions in a module.