Elm Exactly

Figureappendix-derived-forms-expressions

Figure 27, Derived forms of Expressions and Atomic Expressions, in ADerived Forms.

Expressions exp\expm

Derived Form\textnormal{Derived Form}Equivalent Form\textnormal{Equivalent Form}
exp1 op exp2\expm_1\ \opv\ \expm_2(op) (exp1) (exp2)\kw{(}\opv\kw{)}\ \kw{(}\expm_1\kw{)}\ \kw{(}\expm_2\kw{)}infix
if exp1 then exp2 else exp3\kw{if}\ \expm_1\ \kw{then}\ \expm_2\ \kw{else}\ \expm_3case exp1 of Basics.True -> (exp2)case exp1 of ; Basics.False -> exp3\begin{array}{l} \kw{case}\ \expm_1\ \kw{of}\ \kw{Basics.True}\ \kw{->}\ \kw{(}\expm_2\kw{)}\\ \phantom{\kw{case}\ \expm_1\ \kw{of}}\ \kw{;}\ \kw{Basics.False}\ \kw{->}\ \expm_3 \end{array}if
if exp1 then exp1′else if exp2 then exp2′ ⋯else if expn then expn′else exp\begin{array}{l} \kw{if}\ \expm_1\ \kw{then}\ \expm'_1\\ \kw{else}\ \kw{if}\ \expm_2\ \kw{then}\ \expm'_2\ \cdots\\ \kw{else}\ \kw{if}\ \expm_n\ \kw{then}\ \expm'_n\\ \kw{else}\ \expm \end{array}if exp1 then exp1′ else (  if exp2 then exp2′ else ( ⋯    if expn then expn′ else exp )⋯)(n≥2)\begin{array}{l} \kw{if}\ \expm_1\ \kw{then}\ \expm'_1\ \kw{else}\ \kw{(}\\ \;\kw{if}\ \expm_2\ \kw{then}\ \expm'_2\ \kw{else}\ \kw{(}\ \cdots\\ \;\;\kw{if}\ \expm_n\ \kw{then}\ \expm'_n\ \kw{else}\ \expm \ \kw{)}\cdots\kw{)}\\ \qquad (n\geq 2) \end{array}if-chain
exp1 && exp2\expm_1\ \kw{\&\&}\ \expm_2if exp1 then exp2 else Basics.False\kw{if}\ \expm_1\ \kw{then}\ \expm_2\ \kw{else}\ \kw{Basics.False}and
exp1 || exp2\expm_1\ \kw{||}\ \expm_2if exp1 then Basics.True else exp2\kw{if}\ \expm_1\ \kw{then}\ \kw{Basics.True}\ \kw{else}\ \expm_2or
\atpat1⋯atpatn -> exp\kw{\textbackslash}\atpat_1\cdots\atpat_n\ \kw{->}\ \expm\atpat1 -> ⋯ \atpatn -> exp(n≥2)\kw{\textbackslash}\atpat_1\ \kw{->}\ \cdots\ \kw{\textbackslash}\atpat_n\ \kw{->}\ \expm \quad (n\geq 2)lambda-params

Atomic Expressions atexp\atexp

Derived Form\textnormal{Derived Form}Equivalent Form\textnormal{Equivalent Form}
-atexp\kw{-}\atexp(Basics.negate atexp)\kw{(}\kw{Basics.negate}\ \atexp\kw{)}negation
[exp1, ⋯, expn]\kw{[}\expm_1\kw{,}\ \cdots\kw{,}\ \expm_n\kw{]}(exp1 :: ⋯ :: expn :: [ ])(n≥1)\kw{(}\expm_1\ \kw{::}\ \cdots\ \kw{::}\ \expm_n\ \kw{::}\ \kw{[ ]}\kw{)} \qquad (n\geq 1)list
.lab\kw{.}\lab(\{ lab = lab } -> lab)\kw{(}\kw{\textbackslash}\kw{\kwlb}\ \lab\ \kw{=}\ \lab\ \kw{\kwrb}\ \kw{->}\ \lab\kw{)}field-accessor
atexp.lab\atexp\kw{.}\lab(.lab atexp)\kw{(}\kw{.}\lab\ \atexp\kw{)}field-selection
Figure 27: Derived forms of Expressions and Atomic Expressions
Read it in its chapter·Permanent address: /standard/figures/appendix-derived-forms-expressions

Referred to from

Tests (0)

No test of the suite checks this figure yet.

Discussions

Discuss this figure·Search the discussions on GitHub

Discussions are on GitHub; one about this figure has [fig:appendix-derived-forms-expressions] 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.