Elm Exactly
Results / elm /

AliasUnboundVariableTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:restriction modules-alias-tyvars

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A type alias uses only its parameters.

A Standard Definition of Elm?, restriction modules-alias-tyvars: the parameters of an alias are
exactly the type variables of its type. `a` occurs in `List a` but is not a parameter.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-alias-tyvars>

Results

elm-0.19.1

pass
Output
Compiling ...-- UNBOUND TYPE VARIABLE ---------------------- src/AliasUnboundVariableTest.elm

The `Items` type alias uses an unbound type variable `a` in its definition:

18| type alias Items =
19|     List a
             ^
You probably need to change the declaration to something like this:

    type alias Items a = ...

Why? Well, imagine one `Items` where `a` 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

pass
Output
Compiling ...-- UNBOUND TYPE VARIABLE ---------------------- src/AliasUnboundVariableTest.elm

The `Items` type alias uses an unbound type variable `a` in its definition:

18| type alias Items =
19|     List a
             ^
You probably need to change the declaration to something like this:

    type alias Items a = ...

Why? Well, imagine one `Items` where `a` 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

pass
Output
Dependencies ready!
Compiling ...-- UNBOUND TYPE VARIABLE ---------------------- src/AliasUnboundVariableTest.elm

The `Items` type alias uses an unbound type variable `a` in its definition:

18| type alias Items =
19|     List a
             ^
You probably need to change the declaration to something like this:

    type alias Items a = ...

Why? Well, imagine one `Items` where `a` 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

pass
Output
Dependencies ready!
Detected problems in 1 module.
-- UNBOUND TYPE VARIABLE ---------------------- src/AliasUnboundVariableTest.elm

The `Items` type alias uses an unbound type variable `a` in its definition:

18| type alias Items =
19|     List a
             ^
You probably need to change the declaration to something like this:

    type alias Items a = ...

Why? Well, imagine one `Items` where `a` 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/AliasUnboundVariableTest] in its title.

Source

The -- CHECK: lines give the expected output.

module AliasUnboundVariableTest exposing (main)
{-| A type alias uses only its parameters.
A Standard Definition of Elm?, restriction modules-alias-tyvars: the parameters of an alias are
exactly the type variables of its type. `a` occurs in `List a` but is not a parameter.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-alias-tyvars>
-}
-- TAGS: elm-spec, modules-alias-tyvars
-- COMPILE-ERROR: a type alias with an unbound type variable
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type alias Items =
List a
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_AliasUnboundVariableTest, 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-alias-tyvars. It holds for every derivation, with no hypothesis about principality.