Elm Exactly

Derived formif

Stated in ADerived Forms, under Expressions exp\expm.

Derived Form\textnormal{Derived Form}Equivalent Form\textnormal{Equivalent Form}
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}
Read it in its chapter·Permanent address: /standard/derived-forms/if

Tests (6)

  • elm / BoolAndTest
    The `&&` operator gives `True` only when both operands are `True`, checked over all four combinations.
  • elm / BoolOrTest
    The `||` operator gives `False` only when both operands are `False`, checked over all four combinations.
  • elm / InfixIfExtendsRightTest
    An `if` extends as far right as it can: its `else` branch takes in a chain after it.
  • elm / InfixLastOperandAnyExprTest
    The last operand of a chain may be any expression: an `if` or a lambda.
  • elm-core / EqualityBoolIfTest
    The result of `==` and `/=` on `Bool` operands drives an `if` expression correctly.
  • elm-core / NotEqualBoolIfTest
    The result of `/=` on two `Bool` literals is used as the condition of an `if`, for all four combinations of operands; each logs `"yes"` exactly when the operands differ.

Discussions

Discuss this derived form·Search the discussions on GitHub

Discussions are on GitHub; one about this derived form has [df:if] 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.