CustomTypeUnboundRowVariableTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:restriction modules-custom-type-tyvars
Not translated into Lean for the mechanisation of the book: see why.
The extension variable of a record type in a constructor is a parameter of the type. A Standard Definition of Elm?, restriction modules-custom-type-tyvars: every type variable occurring in the constructors, including the extension variable of a record type, is a parameter. `r` is not. <https://elm-test-suite.netlify.app/standard/restrictions/modules-custom-type-tyvars>
Results
elm-0.19.1
passOutput
Compiling ...-- UNBOUND TYPE VARIABLE -------------- src/CustomTypeUnboundRowVariableTest.elm
The `Holder` type uses an unbound type variable `r` in its definition:
18| type Holder
19| = Holder { r | name : String }
^
You probably need to change the declaration to something like this:
type Holder r = ...
Why? Well, imagine one `Holder` where `r` is an Int and another where it is a
Bool. When we explicitly list the type variables, the type checker can see that
they are actually different types.
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- UNBOUND TYPE VARIABLE -------------- src/CustomTypeUnboundRowVariableTest.elm
The `Holder` type uses an unbound type variable `r` in its definition:
18| type Holder
19| = Holder { r | name : String }
^
You probably need to change the declaration to something like this:
type Holder r = ...
Why? Well, imagine one `Holder` where `r` is an Int and another where it is a
Bool. When we explicitly list the type variables, the type checker can see that
they are actually different types.
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- UNBOUND TYPE VARIABLE -------------- src/CustomTypeUnboundRowVariableTest.elm
The `Holder` type uses an unbound type variable `r` in its definition:
18| type Holder
19| = Holder { r | name : String }
^
You probably need to change the declaration to something like this:
type Holder r = ...
Why? Well, imagine one `Holder` where `r` is an Int and another where it is a
Bool. When we explicitly list the type variables, the type checker can see that
they are actually different types.
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- UNBOUND TYPE VARIABLE -------------- src/CustomTypeUnboundRowVariableTest.elm
The `Holder` type uses an unbound type variable `r` in its definition:
18| type Holder
19| = Holder { r | name : String }
^
You probably need to change the declaration to something like this:
type Holder r = ...
Why? Well, imagine one `Holder` where `r` is an Int and another where it is a
Bool. When we explicitly list the type variables, the type checker can see that
they are actually different types.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/CustomTypeUnboundRowVariableTest] in its title.
Source
The -- CHECK: lines give the expected output.
module CustomTypeUnboundRowVariableTest exposing (main)
{-| The extension variable of a record type in a constructor is a parameter of the type.
A Standard Definition of Elm?, restriction modules-custom-type-tyvars: every type variable occurring
in the constructors, including the extension variable of a record type, is a parameter. `r` is not.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-custom-type-tyvars>
-}
-- TAGS: elm-spec, modules-custom-type-tyvars
-- COMPILE-ERROR: a custom type whose constructor uses an unbound extension variable
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type Holder
= Holder { r | name : String }
main =
Html.text "done"
Lean translation
No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Lean has the program as written, in source syntax, and proves what the static semantics says of it (below). See the Lean mechanisation for which tests are in Lean, and why.
Static semantics: Lean proves that the program as written is not legal, so a compiler must reject it (refuse_elm_CustomTypeUnboundRowVariableTest, in StandardElmMech/Certs/). The program breaks a syntactic restriction, which the kernel checks on its syntax tree; no type inference is involved (Stat.not_legal_of_syn): res:modules-custom-type-tyvars. It holds for every derivation, with no hypothesis about principality.