Elm Exactly

Rule 10s-atexp-let

Atomic ExpressionsC⊢atexp⇒τ\jdg{C}{\atexp}{\tau}
C⊢dec⇒VEC+VE⊢exp⇒τC⊢let dec in exp⇒τ\frac{\begin{array}{c}\jdg{C}{\dec}{\VE} \premsep \jdg{C + \VE}{\expm}{\tau}\end{array}}{\begin{array}{c}\jdg{C}{\kw{let}\ \dec\ \kw{in}\ \expm}{\tau}\end{array}}
(10)
Read it in its chapter·Permanent address: /standard/rules/s-atexp-let

Comments

The variables bound by dec\dec are in scope in exp\expm at the type schemes that rule (19) gives them, so exp\expm may use them polymorphically.

TeX source
\defnrule[r:s-atexp-let]
  {\jdg{C}{\dec}{\VE} \premsep \jdg{C + \VE}{\expm}{\tau}}
  {\jdg{C}{\kw{let}\ \dec\ \kw{in}\ \expm}{\tau}}

Tests (5)

  • elm / CombinatorStdlibTCombinatorPipeListIntoComposedOpsTest
    The T combinator, built from S and K inside a `let`, passing `[ 1, 2, 3 ]` to the composition of a sum and a doubling map: the result is 12.
  • elm / LetMultiFuncTest
    Two named functions defined in one `let` and called from later bindings: a local `identity` returns its argument (1) and a local `const` returns the first of two (2).
  • elm / MinimalLetTest
    A let expression with one definition.
  • elm / PolyLetConstTest
    A let-bound polymorphic `const` is used at two different type combinations in the same scope, and each use returns its first argument.
  • elm / PolyLetTailRecTwoTypesTest
    A let-bound, polymorphic, tail-recursive local `foldl` used at two different types in the same expression gives the right result for each.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:s-atexp-let] 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.