Elm Exactly

Rule 84d-app-basic-apply

Application of Values⊢v1 v2⇒v\japp{v_1}{v_2}{v}
k+1=arity(b)v′∈APPLY(b,v1⋯vk v)⊢(b,v1⋯vk) v⇒v′\frac{\begin{array}{c}k+1=\arity(b)\premsep v'\in\APPLY(b,v_1\cdots v_k\,v)\end{array}}{\begin{array}{c}\japp{(b,v_1\cdots v_k)}{v}{v'}\end{array}}
(84)
Read it in its chapter·Permanent address: /standard/rules/d-app-basic-apply

Comments

The result is any member of the set APPLY(b,v1⋯vk v)\APPLY(b,v_1\cdots v_k\,v) (Section 6.5). When the set has two members the rule does not determine the result: this happens only when an equality test reaches two functions, as in (\x -> x) == (\x -> x), which may evaluate to True or to False. When the set is empty, as for Debug.todo, the rule never applies, and the application has no result.

Referred to from

TeX source
\defnrule[r:d-app-basic-apply]
  {k+1=\arity(b)\premsep v'\in\APPLY(b,v_1\cdots v_k\,v)}
  {\japp{(b,v_1\cdots v_k)}{v}{v'}}

Tests (35)

  • elm / AliasForwardTest
    Top-level values defined as another function, `dup = twice` and `plus = (+)`, behave like the function they name.
  • elm / CombinatorBSumMapTest
    The B combinator, built from S and K, composing `sum` with a partially applied `map`: the sum of `[ 1, 2, 3 ]` each plus one is 9.
  • elm / CombinatorListStringTest
    SKI-style combinators applied to lists, strings and functions over them, each printing its result.
  • elm / CombinatorPLengthsTest
    The P combinator, which applies one function to two arguments and combines the results: `p (+) length [ 1, 2, 3 ] [ 4, 5 ]` is 5.
  • elm / CombinatorSFeedTest
    The S combinator, which gives its argument to a function together with a second function's result on that argument: `s (+) double 5` is `5 + double 5`, which is 15.
  • elm / CombinatorSPalindromeTest
    The S combinator with a one-argument string function: `s (++) bang "straw"` is `"straw" ++ bang "straw"`, which is `"strawstraw!"`.
  • elm / CombinatorSpMulTest
    The SP combinator with operator sections as its functions: `sp (*) ((+) 1) ((*) 2) 6` is `7 * 12`, which is 84.
  • elm / CombinatorTPipeTest
    The T combinator, built from S and K, passing `[ 1, 2, 3 ]` to the composition of `sum` and `map ((*) 2)`: the result is 12.
  • elm / CombinatorWConcatTest
    The W combinator, which passes one argument twice, applied to string append: `w (++) "hi"` is `"hihi"`.
  • elm / CompilerIssue1793ComparableTupleLetCrashTest
    Comparing tuples containing a `comparable` in a let binding crashes the compiler.
  • elm / StandardA56PrefixAndOrTest
    `(&&)` and `(||)` used as functions evaluate both arguments, like every other function.
  • elm / WideRecordDecoder26Test
    A 26-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`.
  • elm / WideRecordDecoder30Test
    A 30-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`, with fields of different types near the end.
  • elm / WideRecordDecoder70Test
    A 70-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`.
  • elm-core / CompareCharCaptureTest
    A local insertion sort, `sortWith`, on a list of `Char`, given `compare` itself and given a lambda that calls `compare` with its arguments swapped.
  • elm-core / CompareFloatCaptureTest
    `compare` on `Float` passed as a function value to a local insertion sort, `sortWith`.
  • elm-core / CompareIntCaptureTest
    `compare` on `Int` passed as a function value to a local insertion sort, `sortWith`.
  • elm-core / EqualityBoolIfTest
    The result of `==` and `/=` on `Bool` operands drives an `if` expression correctly.
  • elm-core / EqualityBoolPapTest
    `(==)` partially applied to a `Bool` works as an ordinary predicate passed to the local helpers `map`, `filter` and `any`, written with patterns.
  • elm-core / FloatNegativeZeroTest
    Negative zero (`-0.0`) equals 0.0, and dividing 1.0 by it gives -Infinity while dividing by 0.0 gives Infinity.
  • elm-core / FloatSubTest
    Float subtraction gives the expected value, including when the right operand is a negative literal.
  • elm-core / IntSubTest
    Checks integer subtraction `-`, including subtracting a negative literal.
  • 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.
  • elm-core / NotEqualBoolPapTest
    `(/=)` partially applied to a `Bool`, as `(/=) True` and `(/=) False`, works as a function value passed to the local helpers `map`, `filter` and `any`, written with patterns, over `[ True, False, True, False ]`.
  • elm-core / OrderingEmptyListPapTest
    The operators `<`, `<=`, `>` and `>=` and the function `compare`, partially applied to the empty list, work as function values passed to a local `map`, written with patterns, over `[ [], [ 1 ], [ 1, 2 ] ]`.
  • elm-core / OrderingEmptyStringPapTest
    Tests `<`, `<=`, `>`, `>=` and `compare` partially applied to `""` and passed as functions to a local `map` written with patterns.
  • elm-core / OrderingMixedCaptureTest
    Tests `(<)` and `(>=)` passed as arguments to one polymorphic counting helper, used at `Int`, `Float` and `Char` in the same program.
  • elm-core / StandardA51FunctionEqualityTest
    `==` on two functions gives a Bool; the program goes on.
  • elm-core / TaskSucceedAsArgTest
    `Task.succeed`, passed as a function value to a polymorphic `apply : (a -> b) -> a -> b` with `a` instantiated to `Int`, produces a task that `Task.perform` delivers to `update` with the value 7.
  • elm-core / UtilsEqualityCaptureCharTest
    `(==)` and `(/=)` on `Char` give the same answers when passed as function values as when applied directly.
  • elm-core / UtilsEqualityCaptureFloatTest
    `(==)` and `(/=)` on `Float` give the same answers when passed as function values as when applied directly.
  • elm-core / UtilsEqualityCaptureIntTest
    `(==)` and `(/=)` on `Int` give the same answers when passed as function values as when applied directly.
  • elm-core / UtilsOrderingCaptureCharTest
    `(<)`, `(<=)`, `(>)` and `(>=)` on `Char` give the right answers when passed as function values or applied in prefix form.
  • elm-core / UtilsOrderingCaptureFloatTest
    `(<)`, `(<=)`, `(>)` and `(>=)` on `Float` give the right answers when passed as function values or applied in prefix form.
  • elm-core / UtilsOrderingCaptureIntTest
    `(<)`, `(<=)`, `(>)` and `(>=)` on `Int` give the right answers when passed as function values or applied in prefix form.

Discussions

Discuss this rule·Search the discussions on GitHub

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