Rule 4s-atexp-op
Atomic Expressions
(4)
Comments
Infixed applications of operators are derived forms of this phrase (Appendix A), so this rule gives the type of every application of an operator. The context is absent from the premise, so an operator has the same type scheme in every module, whatever the module declares or imports: a declaration of add in a program does not change the meaning of +.
Referred to from
- The comment on rule
s-atexp-longvar(Chapter 4) - The comment on rule
sm-item-op(Chapter 5)
TeX source
\defnrule[r:s-atexp-op]
{\OTstat(\opv) = (\sigma, \is) \premsep \sigma \succ \tau}
{\jdg{C}{\kw{(}\opv\kw{)}}{\tau}}Tests (92)
- elm / AliasForwardTestTop-level values defined as another function, `dup = twice` and `plus = (+)`, behave like the function they name.
- elm / CompilerIssue1700InfiniteTypeFoldrLambdaHangTestA `foldr` lambda that conses a list onto an element (`uniq :: elem`) is rejected with an infinite-type error.
- elm / CompilerIssue1793ComparableTupleLetCrashTestComparing tuples containing a `comparable` in a let binding crashes the compiler.
- elm / CompilerIssue2066RankCrashNumberFloatTestAnnotating `number` arguments compared with a `Float` crashes the type checker.
- elm / EmbeddedNothingPolymorphicTest`Nothing`, `[]` and `""` pass unchanged through the polymorphic `identity`, the first two then also through a function with a concrete type.
- elm / FunctionCompappendWithStringTestA function whose arguments have the `compappend` constraint (comparable and appendable) works when called with `String`s.
- elm / FunctionUnannotatedCompappendTestA module containing an unannotated function that both compares and appends its arguments compiles, with the type `compappend` inferred.
- elm / IndirectCallFloatTestFunctions of type `Float -> Float` passed to higher-order functions, including one built with `>>`, return the right Float values.
- 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 / TooManyArgsTooManyArgumentsToAnOperatorTestAn operator function given three arguments is rejected with a TOO MANY ARGS error.
- elm / TypeMismatchAppendableAgainstATupleTestA list whose tuple elements disagree in both components is rejected with a TYPE MISMATCH.
- elm / TypeMismatchArgumentToAnOperatorFunctionTestA `String` passed to the operator function `(+)` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolLeftOfAppendTestA `Bool` on the left of `++` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolLeftOfMinusTestA `Bool` on the left of `-` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolLeftOfPowerTestA `Bool` on the left of `^` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolLeftOfTimesTestA `Bool` on the left of `*` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolRightOfAppendWithAStringTestA `Bool` on the right of `++` after a `String` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchBoolRightOfPlusTest`1 + True` is rejected with a TYPE MISMATCH, because `+` takes two numbers and `True` is a `Bool`.
- elm / TypeMismatchBoolsComparedTest`True < False` is rejected with a TYPE MISMATCH, because `<` takes comparable values and `Bool` is not comparable.
- elm / TypeMismatchCompappendAgainstARigidVarTestA value used with both `++` and `<` cannot share a type with an annotation's type variable, and the program is rejected with a TYPE MISMATCH.
- elm / TypeMismatchCompappendAgainstATupleTestA list whose two tuple entries disagree, one holding a value used with both `++` and `<`, the other a tuple of numbers in that position, is rejected with a TYPE MISMATCH.
- elm / TypeMismatchCompappendListEntryWithABoolTestA list holding a value used with both `++` and `<` alongside `True` is rejected with a TYPE MISMATCH, because `Bool` can be neither appended nor compared.
- elm / TypeMismatchComparableAgainstATupleTestA list whose two tuple entries disagree, one holding a value used with `<`, the other a tuple of numbers in that position, is rejected with a TYPE MISMATCH.
- elm / TypeMismatchComposedWithANumberTest`not >> 1` is rejected with a TYPE MISMATCH, because `>>` composes two functions and `1` is a number.
- elm / TypeMismatchConsedOntoABoolTest`1 :: True` is rejected with a TYPE MISMATCH, because the right side of `::` must be a list and `True` is a `Bool`.
- elm / TypeMismatchConsedOntoAMaybeTest`1 :: Just 1` is rejected with a TYPE MISMATCH, because the right side of `::` must be a list and `Just 1` is a `Maybe`.
- elm / TypeMismatchFloatComparedForEqualityTestThe compiler rejects `1.5 == "a"`, an equality test between a `Float` and a `String`, with a TYPE MISMATCH error.
- elm / TypeMismatchFloatLeftOfAppendTestThe compiler rejects a `Float` on the left of `++`, which only accepts strings and lists, with a TYPE MISMATCH error.
- elm / TypeMismatchFloatLeftOfIntDivideTestThe compiler rejects the `Float` literal `1.5` on the left of the integer division operator `//`, with a TYPE MISMATCH error.
- elm / TypeMismatchFloatRightOfIntDivideTestThe compiler rejects the `Float` literal `1.5` on the right of the integer division operator `//`, with a TYPE MISMATCH error.
- elm / TypeMismatchFloatRightOfMinusWithIntTestThe compiler rejects `n - f`, subtracting a `Float` from an `Int`, with a TYPE MISMATCH error, because Elm has no implicit conversion between the two.
- elm / TypeMismatchFloatRightOfPlusWithIntTestThe compiler rejects `n + f`, adding a `Float` to an `Int`, with a TYPE MISMATCH error, because Elm has no implicit conversion between the two.
- elm / TypeMismatchFloatRightOfPowerWithIntTestThe compiler rejects `n ^ f`, raising an `Int` to a `Float` power, with a TYPE MISMATCH error, because `^` needs both sides to be the same number type.
- elm / TypeMismatchFloatRightOfTimesWithIntTestThe compiler rejects `n * f`, multiplying an `Int` by a `Float`, with a TYPE MISMATCH error, because Elm has no implicit conversion between the two.
- elm / TypeMismatchFunctionLeftOfGreaterThanTestThe compiler rejects `not > not`, comparing two functions with `>`, with a TYPE MISMATCH error, because functions are not `comparable`.
- elm / TypeMismatchIntAgainstNumberAfterAMismatchTestThe compiler rejects a list of pairs whose second entry has a `String` first component where the first entry has a number, with a TYPE MISMATCH error.
- elm / TypeMismatchIntRightOfAppendTestThe compiler rejects `"a" ++ n`, appending an `Int` to a `String`, with a TYPE MISMATCH error.
- elm / TypeMismatchIntRightOfAppendWithAListTestAppending an `Int` to a list with `++` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchIntRightOfDivideTestDividing by an `Int` with `/` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchIntRightOfMinusWithFloatTestSubtracting an `Int` from a `Float` with `-` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchIntRightOfPlusWithFloatTestAdding an `Int` to a `Float` with `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchIntRightOfPowerWithFloatTestRaising a `Float` to an `Int` power with `^` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchIntRightOfTimesWithFloatTestMultiplying a `Float` by an `Int` with `*` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListConsedOntoAListOfStringsTestConsing a list onto a list of strings with `::` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListMultipliedTestMultiplying a list with `*` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListRightOfAppendWithAStringTestAppending a list to a `String` with `++` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListRightOfPlusTestAdding a list to a number with `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListRightOfTimesTestMultiplying a number by a list with `*` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchListsAddedTestAdding two lists with `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchMaybeConsedOntoAListOfStringsTestConsing a `Maybe` onto a list of strings with `::` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchNumberAndAppendableListEntriesTestA list literal whose entries are `a + 1` and `b ++ b` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchNumberAndCompappendListEntriesTestA list literal whose entries are `a + 1` and a value `c` that is both appended (`b ++ b`) and compared (`c < c`) is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchNumberIntoNotWithPipeLeftTestApplying `not` to a number with `<|` (`not <| 1`) is rejected with a TYPE MISMATCH error, because `not` takes a `Bool`.
- elm / TypeMismatchNumberLeftOfComposeRightTestA number as the left operand of `>>` (`1 >> not`) is rejected with a TYPE MISMATCH error, because `>>` composes two functions.
- elm / TypeMismatchNumberLeftOfPipeLeftTestA number as the left operand of `<|` (`1 <| 2`) is rejected with a TYPE MISMATCH error, because `<|` applies its left operand as a function.
- elm / TypeMismatchNumberListEntryWithAnAliasTestA list literal holding a number and a value of the record alias `N` (`[ 1, n ]`) is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchNumberPipedIntoANumberTestPiping a number into another number (`1 |> 2`) is rejected with a TYPE MISMATCH error, because `|>` applies its right operand as a function.
- elm / TypeMismatchNumberPipedIntoNotTestPiping a number into `not` (`1 |> not`) is rejected with a TYPE MISMATCH error, because `not` takes a `Bool`.
- elm / TypeMismatchNumberPlusAppendableTestAppending to the result of an addition (`(a + 1) ++ b`) is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchRecordLeftOfAtMostTestComparing two records with `<=` is rejected with a TYPE MISMATCH error, because `<=` takes `comparable` operands and records are not comparable.
- elm / TypeMismatchRigidAppendableAddedTestAdding two values of an annotated `appendable` type with `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidExtensionWhereFlexibleAfterAMismatchTestAn extensible record argument placed in a list beside an unannotated local value is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidVarAppendedTestAppending two values of an unconstrained annotated type variable with `++` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidVarComparedTestComparing values of an unconstrained annotated type variable with `<` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringAppendedToListTestAppending a `String` to a list with `++` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringLeftOfConsTestConsing a `String` onto a list of numbers with `::` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringLeftOfDivideTestA `String` as the left operand of `/` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringLeftOfIntDivideTestA `String` as the left operand of `//` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringLeftOfLessThanTestComparing a `String` with a number using `<` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringLeftOfPlusTestA `String` as the left operand of `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfAtLeastTestComparing a number with a `String` using `>=` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfAtMostTestComparing a number with a `String` using `<=` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfGreaterThanTestComparing a number with a `String` using `>` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfMinusTestA `String` as the right operand of `-` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfNotEqualsTestComparing a number with a `String` using `/=` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfPlusTestA `String` as the right operand of `+` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfPowerTestA `String` as the right operand of `^` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchStringRightOfTimesTestA `String` as the right operand of `*` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTupleAgainstAnAliasTestA list holding a value of an alias for `Int` and a tuple is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTwentyEightTypeVariablesTestUsing a function of 28 unannotated arguments as a number is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTwoComparableVarsTestA list mixing tuples whose first components have different custom types is rejected with a TYPE MISMATCH.
- elm / TypeMismatchUnitLeftOfAtLeastTestComparing two unit values with `>=` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchUnitsOnBothSidesTestA list of pairs whose second components differ, `( (), 1 )` and `( (), "a" )`, is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchUnknownTypeAgainstANumberTestA function whose case branches return `( Just 1, h )` and `( True, x + 1 )` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchUnknownTypeAgainstARigidNumberTestA function annotated `number -> ( Bool, number )` whose case branches return `( Just 1, h )` and `( True, x )` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchUnknownTypeAgainstARigidVarTestA function annotated `a -> ( Bool, a )` whose case branches return `( Just 1, h )` and `( True, x )` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchUnknownTypesOnBothSidesTestA list of pairs `( h, 1 )` and `( h, "a" )`, built inside a case on `[ 1, "a" ]`, is rejected with a TYPE MISMATCH error.
- elm / UnknownOperatorAnUnknownOperatorTestUsing an operator that no module defines, `1 <=> 2`, is rejected with an UNKNOWN OPERATOR error.
- elm-core / OrderingMixedCaptureTestTests `(<)` and `(>=)` passed as arguments to one polymorphic counting helper, used at `Int`, `Float` and `Char` in the same program.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:s-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.