Rule 82d-app-con
Application of Values
(82)
Comments
No side condition 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 / CharAstralCustomFieldTestAn 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 / CustomTypeFuncFieldTestA custom type whose single constructor wraps a function can be unwrapped by an argument pattern and the function called.
- elm / CustomTypeMultiFieldTestA value of a custom type whose constructor has three arguments of different types (`String`, `Int`, `Bool`) can be built and logged.
- elm / CustomTypeNestedTestA value of a recursive, parameterised custom type (a binary tree with values in its leaves) can be built several levels deep and logged.
- elm / EmbeddedNilInCustomTypeTestAn empty list stored in a custom type constructor and taken back out by a `case` is still empty, with length 0.
- elm / EmbeddedNothingCallbackTestA function that pattern-matches a `Maybe` returns `Nothing` for `Nothing` and applies its function argument to a `Just` payload.
- elm / EmbeddedNothingRecursiveTestA recursive list search returns `Just` the first matching element, or `Nothing` once it reaches the end of the list.
- elm / ListConsCharTestA `List Char` literal holds its characters in order, and `::` prepends a character to it.
- elm / ListConsFloatTestA `List Float` literal holds its numbers in order, and `::` prepends a number to it.
- elm / ListConsIntTestA `List Int` literal holds its numbers in order, and `::` prepends a number to it.
- elm / ListConsTestThe cons operator `::` builds one-, two- and three-element lists onto `[]`.
- elm / ListLiteralDebugLogKindTestValues returned by `Debug.log` keep their value when used in a closure, a tuple, a function argument, a list literal and a `::` cons.
- elm / ListLiteralTestList literals of one, three and five Int elements log their elements in order.
- elm / LssGapCtorAsValueA custom type constructor passed as a function argument builds the value it is applied to.
- elm / LssGapCtorInListA custom type constructor stored in a list can be taken out and applied.
- elm / LssGapCtorScaleConstructors of arity one to four build values that pattern matches in function arguments take apart again.
- elm / LssGapCustomTypeFnA 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 / PapEtaCtorProbeTests point-free top-level functions defined by partially applying a two-argument function, stored in a constructor, pattern-matched back out and applied.
- elm / ResultErrTestChecks 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 / ResultOkTestChecks 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 / StandardCoreEvaluationExamplesTestSmall 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 / WideCtorField24TestA 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 / WideCtorMixedTestA custom type constructor with 60 fields, cycling through `Int`, `Float`, `Char`, `String` and `Bool`, supports pattern matching, equality and printing.
- elm / WrapperUnionFieldTestA 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.