Rule 28s-ty-con
Type Expressions
(28)
Comments
For to be defined, must have arity , so a type constructor is never partially applied. Application of a type function performs the substitution, so a type alias denotes its expansion, and an alias with a row parameter applies only to a record type.
Referred to from
- The comment on rule
sm-typbind(Chapter 5)
TeX source
\defnrule[r:s-ty-con]
{C(\longtycon) = (\theta, \VE) \premsep \jdg{C}{\ty_i}{\tau_i} \quad (1 \le i \le k)}
{\jdg{C}{\longtycon\ \ty_1 \cdots \ty_k}{\theta(\tau_1, \cdots, \tau_k)}}Tests (37)
- elm / CompilerIssue1550RecordExtensionDuplicateFieldTestExtending a record type with a field it already has is accepted, and the field's type is replaced.
- elm / CompilerIssue1785ExtensibleAliasOfUnitTestAn extensible record alias applied to `()`, a record extending a non-record, is rejected with an error.
- elm / CompilerIssue1896ExtendCustomTypeCrashTestExtending a custom type as if it were a record crashes the compiler while reporting the error.
- elm / CompilerIssue1916PhantomExtensibleAliasCrashTestA phantom type over an extensible record in a function alias crashes the compiler.
- elm / CompilerIssue1952ExtendIntCrashTestExtending `Int` as if it were a record crashes the compiler while reporting the error.
- elm / CompilerIssue2019AliasOfTypeVariableTestAn alias `MyType k = k` is not interchangeable with `k` in a result position.
- elm / CompilerIssue2064ExtendStringNotEnoughBytesTestExtending `String` as if it were a record inside a custom type crashes the compiler.
- elm / CompilerIssue2072ExtendUnitInResultCrashTestA result annotation that extends `()` as if it were a record must be rejected with an error report, not crash the compiler.
- elm / CompilerIssue2083ExtendCustomTypeFieldAccessCrashTestExtending a custom type as if it were a record must be rejected with an error report, not crash the compiler.
- elm / CompilerIssue2097ExtensibleUnitArgCrashTestAn extensible-record alias applied to `()` must be rejected with an error report, not crash the compiler.
- elm / CompilerIssue2176ExtensibleUnitAliasCrashTestA function between records typed with an extensible alias applied to `()` must be rejected with an error report, not crash the compiler.
- elm / CompilerIssue2182ExtensibleFunctionAliasCrashTestAn alias that extends its parameter with a field the parameter already has is not a type.
- elm / CompilerIssue2252IdentityAliasTestA type alias `Identity a = a` is interchangeable with `a`, so `map change = change` type-checks against `(a -> b) -> Identity a -> Identity b`.
- elm / CompilerIssue2298IdentityAliasResultTestA type alias `Msg a = a` in an annotation's result is interchangeable with `a`, so `make = identity` type-checks against `a -> Msg a`.
- elm / CovEtaDebugLogTestChecks a function defined with fewer parameters than its annotated type: `mk : Int -> Fn`, where `Fn` is an alias of `Int -> Int`, takes one parameter and returns a `let`-bound function whose body calls `Debug.log`.
- elm / CovLambdaBoundaryCaseBoundaryUnderAFunctionAliasTestA function whose result type is a type alias for a function type, with a `case` that returns a different lambda per branch.
- elm / EtaExpandStateFunctionSequenceTestA state-passing `sequence` written with `andThen` and `pure` over a function type alias, `St a = Int -> a`, whose definitions take more parameters than their annotations show.
- elm / EtaExpandStateTestA state monad over the function alias `St a = Int -> ( Int, a )`, with `sequence` written recursively using `andThen` and `pure`, threads its state correctly.
- elm / HoleyAliasTwoParamsTestA type alias with two type parameters, used as a constructor field, keeps each parameter bound to its own argument.
- elm / PolyStepLoopFloatResultTestA polymorphic state-threading loop, driven by a `Step state a` custom type, returns a `Float` result and the threaded state correctly.
- elm / PolyStepLoopFoldMIntTestA monadic fold, `foldM`, built on a polymorphic `Step`-driven state loop, sums a list of `Int`s and threads its state correctly.
- elm / PortAliasEchoTestAn outgoing port whose type is written through a type alias, `port echoOut : Out msg` with `type alias Out msg = Payload -> Cmd msg`, sends its record payload, and the record comes back unchanged through an incoming port.
- elm / QualifiedTypeNotExposedTestA qualified type that its module does not expose is not a type: `List.Bar` is rejected.
- elm / RecordNarrow03FullAnnotationTestA let-bound helper annotated with concrete record aliases, folded over two nested records with `List.foldl`, reads the right nested field.
- elm / RowVariableAloneTestA record type's extension variable, written alone, is the record of the other fields.
- elm / TypeConstructorTooFewArgsTestA type constructor given fewer arguments than it takes is not a type: `List -> List` is rejected.
- elm / TypeMismatchAliasWhereARecordTestA value of a record alias used where a record with a differently typed field is expected is rejected with a TYPE MISMATCH.
- elm / TypeMismatchAliasedRecordFieldOfTheWrongTypeTestA record whose field has the wrong type for its record alias annotation is rejected with a TYPE MISMATCH.
- elm / TypeMismatchFunctionInATypeArgumentTestThe compiler rejects a list holding `Just not` as the body of a definition annotated `Maybe (Int -> Int)`, with a TYPE MISMATCH error.
- elm / TypeMismatchImportedTypeNamedLikeAnAliasTestThe compiler rejects a list holding both `Basics.True` and a value of a local alias named `Bool`, which stands for `Int`, with a TYPE MISMATCH error.
- elm / TypeMismatchLocalTypeNamedLikeAnImportedOneTestA local type named `Maybe` is a different type from the core `Maybe`, so mixing them is rejected with a TYPE MISMATCH.
- elm / TypeMismatchParameterisedAliasTestGiving a `Box Int` where a `Box String` is annotated is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchRigidVarAgainstItsListTestReturning an argument of type `a` where the annotation says `List a` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchRigidVarAgainstItsMaybeTestReturning an argument of type `a` where the annotation says `Maybe a` 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 / TypeMismatchTwoAliasedRecordsTestA value of one record alias annotated as a different record alias is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTypeWhereAnAliasTestA value annotated with a type alias of `Int` but defined as a `String` is rejected with a TYPE MISMATCH error.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:s-ty-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.