Elm Exactly
Results / elm /

AliasUnusedParameterTest

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 has no unused parameter.

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

Results

elm-0.19.1

pass
Output
Compiling ...-- UNUSED TYPE VARIABLE ----------------------- src/AliasUnusedParameterTest.elm

Type alias `Height` does not use the `a` type variable.

17|>type alias Height a =
18|     Int

I recommend removing `a` from the declaration, like this:

    type alias Height = ...

Why? Well, if I allowed `type alias Height a = Float` I would need to answer
some weird questions. Is `Height Bool` the same as `Float`? Is `Height Bool` the
same as `Height Int`? My solution is to not need to ask them!

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- UNUSED TYPE VARIABLE ----------------------- src/AliasUnusedParameterTest.elm

Type alias `Height` does not use the `a` type variable.

17|>type alias Height a =
18|     Int

I recommend removing `a` from the declaration, like this:

    type alias Height = ...

Why? Well, if I allowed `type alias Height a = Float` I would need to answer
some weird questions. Is `Height Bool` the same as `Float`? Is `Height Bool` the
same as `Height Int`? My solution is to not need to ask them!

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- UNUSED TYPE VARIABLE ----------------------- src/AliasUnusedParameterTest.elm

Type alias `Height` does not use the `a` type variable.

17|>type alias Height a =
18|     Int

I recommend removing `a` from the declaration, like this:

    type alias Height = ...

Why? Well, if I allowed `type alias Height a = Float` I would need to answer
some weird questions. Is `Height Bool` the same as `Float`? Is `Height Bool` the
same as `Height Int`? My solution is to not need to ask them!

Detected problems in 1 module.

lamdera-1.5.0

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

Type alias `Height` does not use the `a` type variable.

17|>type alias Height a =
18|     Int

I recommend removing `a` from the declaration, like this:

    type alias Height = ...

Why? Well, if I allowed `type alias Height a = Float` I would need to answer
some weird questions. Is `Height Bool` the same as `Float`? Is `Height Bool` the
same as `Height Int`? My solution is to not need to ask them!

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/AliasUnusedParameterTest] in its title.

Source

The -- CHECK: lines give the expected output.

module AliasUnusedParameterTest exposing (main)
{-| A type alias has no unused parameter.
A Standard Definition of Elm?, restriction modules-alias-tyvars: the parameters of an alias are
exactly the type variables of its type. `a` does not occur in `Int`. <https://elm-test-suite.netlify.app/standard/restrictions/modules-alias-tyvars>
-}
-- TAGS: elm-spec, modules-alias-tyvars
-- COMPILE-ERROR: a type alias with an unused parameter
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type alias Height a =
Int
h : Height String
h =
1
main =
Html.text (Debug.toString h)

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_AliasUnusedParameterTest, 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.