Elm Exactly

Rule 82d-app-con

Application of Values⊢v1 v2⇒v\japp{v_1}{v_2}{v}
⊢(con v1⋯vk) v⇒con v1⋯vk v\frac{\begin{array}{c}\end{array}}{\begin{array}{c}\japp{(\con\ v_1\cdots v_k)}{v}{\con\ v_1\cdots v_k\ v}\end{array}}
(82)
Read it in its chapter·Permanent address: /standard/rules/d-app-con

Comments

No side condition k<arity(con)k<\arity(\con) is needed: in a program that elaborates a constructor value is applied only while it awaits arguments. Thus Just applied to 1 gives the complete constructor value Just 1.

TeX source
\defnrule[r:d-app-con]
  {}
  {\japp{(\con\ v_1\cdots v_k)}{v}{\con\ v_1\cdots v_k\ v}}

Tests (25)

  • elm / CharAstralCustomFieldTest
    An astral `Char` (code point above 0xFFFF) stored in a custom-type constructor's field keeps its code point when read back by pattern matching.
  • elm / CustomTypeFuncFieldTest
    A custom type whose single constructor wraps a function can be unwrapped by an argument pattern and the function called.
  • elm / CustomTypeMultiFieldTest
    A value of a custom type whose constructor has three arguments of different types (`String`, `Int`, `Bool`) can be built and logged.
  • elm / CustomTypeNestedTest
    A value of a recursive, parameterised custom type (a binary tree with values in its leaves) can be built several levels deep and logged.
  • elm / EmbeddedNilInCustomTypeTest
    An empty list stored in a custom type constructor and taken back out by a `case` is still empty, with length 0.
  • elm / EmbeddedNothingCallbackTest
    A function that pattern-matches a `Maybe` returns `Nothing` for `Nothing` and applies its function argument to a `Just` payload.
  • elm / EmbeddedNothingRecursiveTest
    A recursive list search returns `Just` the first matching element, or `Nothing` once it reaches the end of the list.
  • elm / ListConsCharTest
    A `List Char` literal holds its characters in order, and `::` prepends a character to it.
  • elm / ListConsFloatTest
    A `List Float` literal holds its numbers in order, and `::` prepends a number to it.
  • elm / ListConsIntTest
    A `List Int` literal holds its numbers in order, and `::` prepends a number to it.
  • elm / ListConsTest
    The cons operator `::` builds one-, two- and three-element lists onto `[]`.
  • elm / ListLiteralDebugLogKindTest
    Values returned by `Debug.log` keep their value when used in a closure, a tuple, a function argument, a list literal and a `::` cons.
  • elm / ListLiteralTest
    List literals of one, three and five Int elements log their elements in order.
  • elm / LssGapCtorAsValue
    A custom type constructor passed as a function argument builds the value it is applied to.
  • elm / LssGapCtorInList
    A custom type constructor stored in a list can be taken out and applied.
  • elm / LssGapCtorScale
    Constructors of arity one to four build values that pattern matches in function arguments take apart again.
  • elm / LssGapCustomTypeFn
    A function stored in a custom type constructor can be pattern matched out and applied: `useBox (Box double) 7` prints 14.
  • elm / MaybeJustTest
    `Just` wraps an Int, a String and a Bool, and `Debug.log` prints each as `Just <value>`.
  • elm / PapEtaCtorProbe
    Tests point-free top-level functions defined by partially applying a two-argument function, stored in a constructor, pattern-matched back out and applied.
  • elm / ResultErrTest
    Checks that `Err` builds a `Result` around a `String` and around an `Int`, and that `Debug.log` prints them as `Err "failed"` and `Err 404`.
  • elm / ResultOkTest
    Checks that `Ok` builds a `Result` around an `Int` and around a `String`, and that `Debug.log` prints them as `Ok 42` and `Ok "success"`.
  • elm / StandardCoreEvaluationExamplesTest
    Small programs for rules of the dynamic semantics of the Core that other tests reach only in passing, and examples from the Comments of A Standard Definition of Elm?, Chapter 6.
  • elm / WideCtorField24Test
    A custom type constructor with 27 fields, 25 `Int`s followed by a `Float` and a `Char`, keeps every field, and pattern matching reads back the later ones.
  • elm / WideCtorMixedTest
    A custom type constructor with 60 fields, cycling through `Int`, `Float`, `Char`, `String` and `Bool`, supports pattern matching, equality and printing.
  • elm / WrapperUnionFieldTest
    A single-constructor custom type can wrap a record whose field is itself a custom type, and a nested `case` reads the payload of that field.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:d-app-con] 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.