Skip to content

Instantly share code, notes, and snippets.

@bChiquet
Created November 23, 2019 17:56
Show Gist options
  • Save bChiquet/a964266d47cb893badfce19f5c458e84 to your computer and use it in GitHub Desktop.
Save bChiquet/a964266d47cb893badfce19f5c458e84 to your computer and use it in GitHub Desktop.
Quoted from parser.y
Coeffect :: { Coeffect }
: INT { let TokenInt _ x = $1 in CNat x }
| '' { infinity }
| FLOAT { let TokenFloat _ x = $1 in CFloat $ myReadFloat x }
| CONSTR { case (constrString $1) of
"Public" -> Level publicRepresentation
"Private" -> Level privateRepresentation
"Unused" -> Level unusedRepresentation
"Inf" -> infinity
x -> error $ "Unknown coeffect constructor `" <> x <> "`" }
| VAR { CVar (mkId $ symString $1) }
| Coeffect '..' Coeffect { CInterval $1 $3 }
| Coeffect '+' Coeffect { CPlus $1 $3 }
| Coeffect '*' Coeffect { CTimes $1 $3 }
| Coeffect '-' Coeffect { CMinus $1 $3 }
| Coeffect '^' Coeffect { CExpon $1 $3 }
| Coeffect "/\\" Coeffect { CMeet $1 $3 }
| Coeffect "\\/" Coeffect { CJoin $1 $3 }
| '(' Coeffect ')' { $2 }
| '{' Set '}' { CSet $2 }
| Coeffect ':' Type { normalise (CSig $1 $3) }
| '(' Coeffect ',' Coeffect ')' { CProduct $2 $4 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment