Rule 15s-exp-lambda
Expressions
(15)
Comments
The variables bound by receive types, not type schemes, so a parameter has one type throughout . Restriction 2 of Section 4.11 requires to be exhaustive.
TeX source
\defnrule[r:s-exp-lambda]
{\jdg{C}{\atpat}{(\VE, \tau)} \premsep \jdg{C + \VE}{\expm}{\tau'}}
{\jdg{C}{\kw{\textbackslash}\ \atpat\ \kw{->}\ \expm}{\tau \rightarrow \tau'}}Tests (17)
- elm / AnonymousFunctionTestAnonymous functions work as the function argument of higher-order functions.
- elm / CaseInLambdaTestChecks that a `case` expression on a `Bool` inside an anonymous function evaluates correctly, both when the lambda is bound to a name and when it is passed straight to another function.
- elm / CompilerIssue1951OpenRecordLetCrashTestUnifying a closed and an open record type in let bindings crashes the compiler.
- elm / CompilerIssue1975LetOrderCrashTestA type error in a let block crashes the compiler, depending on the names of its bindings.
- elm / CompilerIssue2146RoseLambdaPatternCrashTestA type error involving a lambda pattern on a custom type must be reported normally, not crash the compiler.
- elm / CovTailRecSplitATripleParameterTestA self tail-recursive function that destructures a triple of `Int`, `Int` and `Float` in its parameter pattern and rebuilds it on each call.
- elm / InfiniteTypeSelfAppliedArgumentOnBothSidesTestA function argument applied to itself is rejected with an INFINITE TYPE error.
- elm / TooManyArgsTooManyArgumentsToALambdaTestApplying a one-argument lambda to two arguments, `(\a -> a + 1) 1 2`, is rejected with a TOO MANY ARGS error.
- elm / TypeMismatchAccessorUnderIntTestA field accessor function annotated as `Int` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchLambdaArgumentPatternTestApplying a lambda with a tuple pattern to a number is rejected with a TYPE MISMATCH.
- elm / TypeMismatchLambdaCallAsAnArgumentTestPassing the result of a lambda call to `not` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidNumberAsFunctionTestReturning a lambda where the annotation promises a `number` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidVarAsFunctionTestReturning a lambda where the annotation promises a type variable `a` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchSelfAppliedArgumentAgainstANumberTestAn unannotated function argument that is applied to itself and also used as a numeric function is rejected with a TYPE MISMATCH.
- elm / TypeMismatchSelfAppliedArgumentAgainstARigidNumberTestA local function argument that is applied to itself and also listed beside a function involving an annotated `number` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchSelfAppliedArgumentAgainstARigidVarTestA local function argument that is applied to itself and also listed beside a function involving an annotated type variable is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTwoArgumentLambdaWhereOneTestA two-argument lambda annotated as `Int -> Int` is rejected with a TYPE MISMATCH.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:s-exp-lambda] 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.