Elm Exactly

Rule 18s-mrule

Match RulesC⊢mrule⇒τ\jdg{C}{\mrule}{\tau}
C⊢pat⇒(VE,τ)C+VE⊢exp⇒τ′C⊢pat -> exp⇒τ→τ′\frac{\begin{array}{c}\jdg{C}{\pat}{(\VE, \tau)} \premsep \jdg{C + \VE}{\expm}{\tau'}\end{array}}{\begin{array}{c}\jdg{C}{\pat\ \kw{->}\ \expm}{\tau \rightarrow \tau'}\end{array}}
(18)
Read it in its chapter·Permanent address: /standard/rules/s-mrule

Comments

This rule lets new free type variables enter the context: the types of the variables of pat\pat are chosen in elaborating pat\pat, and they may have to agree with the explicit variables of annotations within exp\expm.

TeX source
\defnrule[r:s-mrule]
  {\jdg{C}{\pat}{(\VE, \tau)} \premsep \jdg{C + \VE}{\expm}{\tau'}}
  {\jdg{C}{\pat\ \kw{->}\ \expm}{\tau \rightarrow \tau'}}

Tests (2)

  • elm / CaseBranchSelectionTest
    A `case` tries its branches in order: a branch whose pattern fails passes the value on, and the first that matches is evaluated with its pattern's bindings.
  • elm / MinimalCaseTest
    A case expression with one rule whose pattern is a variable.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:s-mrule] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.