Rule 68d-atexp-op
Atomic Expressions
(68)
Comments
The value of an operator does not depend on , so a variable that a program declares cannot capture an operator: a top-level add of a module leaves (+) unchanged. The operator values (&&) and (||) denote functions of the initial basis, which receive both arguments as values: in (&&) False e the expression e is evaluated. Only the infixed forms e1 && e2 and e1 || e2, which are derived forms (Appendix A), evaluate their second operand conditionally.
Referred to from
- The comment on rule
dm-expitem-op(Chapter 7)
TeX source
\defnrule[r:d-atexp-op]
{}
{\jdg{E}{\kw{(}\opv\kw{)}}{\OTdyn(\opv)}}Tests (32)
- elm / AliasForwardTestTop-level values defined as another function, `dup = twice` and `plus = (+)`, behave like the function they name.
- elm / CombinatorBSumMapTestThe 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 / CombinatorCConsTestThe C combinator, which swaps two arguments, built from S and K and applied to the cons operator: `c (::) [ 2, 3 ] 1` is `1 :: [ 2, 3 ]`.
- elm / CombinatorListStringTestSKI-style combinators applied to lists, strings and functions over them, each printing its result.
- elm / CombinatorPLengthsTestThe P combinator, which applies one function to two arguments and combines the results: `p (+) length [ 1, 2, 3 ] [ 4, 5 ]` is 5.
- elm / CombinatorSFeedTestThe 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 / CombinatorSPalindromeTestThe S combinator with a one-argument string function: `s (++) bang "straw"` is `"straw" ++ bang "straw"`, which is `"strawstraw!"`.
- elm / CombinatorSpMulTestThe SP combinator with operator sections as its functions: `sp (*) ((+) 1) ((*) 2) 6` is `7 * 12`, which is 84.
- elm / CombinatorTPipeTestThe T combinator, built from S and K, passing `[ 1, 2, 3 ]` to the composition of `sum` and `map ((*) 2)`: the result is 12.
- elm / CombinatorWConcatTestThe W combinator, which passes one argument twice, applied to string append: `w (++) "hi"` is `"hihi"`.
- elm / InfixPrecApplicationFirstTestApplication binds more tightly than any operator.
- elm / StandardA56PrefixAndOrTest`(&&)` and `(||)` used as functions evaluate both arguments, like every other function.
- 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 / TailRecCaseDestructTestSelf tail-recursive functions whose tail calls sit in a `case` branch that destructures a list with `x :: xs` give the right results.
- elm-core / CompositionTestFunction composition with `>>` and `<<`, and the pipe operator `|>`.
- elm-core / EqualityBoolIfTestThe 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 / FloatNegativeZeroTestNegative zero (`-0.0`) equals 0.0, and dividing 1.0 by it gives -Infinity while dividing by 0.0 gives Infinity.
- elm-core / FloatSubTestFloat subtraction gives the expected value, including when the right operand is a negative literal.
- elm-core / IntSubTestChecks integer subtraction `-`, including subtracting a negative literal.
- elm-core / NotEqualBoolIfTestThe 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 / OrderingEmptyListPapTestThe 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 / OrderingEmptyStringPapTestTests `<`, `<=`, `>`, `>=` and `compare` partially applied to `""` and passed as functions to a local `map` written with patterns.
- elm-core / OrderingMixedCaptureTestTests `(<)` and `(>=)` passed as arguments to one polymorphic counting helper, used at `Int`, `Float` and `Char` in the same program.
- elm-core / PipelineTestTests the pipeline operators `|>` and `<|`: a chain of forward pipes, a forward pipe into a partially applied local `map`, written with patterns, and a chain of backward pipes.
- 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-atexp-op] 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.