Elm Exactly
Results / elm /

TopLevelConstructorTwiceTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:restriction modules-constructors-distinct

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
Two custom types may not declare the same constructor.

A Standard Definition of Elm?, restriction modules-constructors-distinct: no module may declare the
same constructor twice. <https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>

Results

elm-0.19.1

pass
Output
Compiling ...-- NAME CLASH ----------------------------- src/TopLevelConstructorTwiceTest.elm

This file defines multiple `C` type constructors. One here:

22|     = C String
          ^
And another one here:

18|     = C Int
          ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- NAME CLASH ----------------------------- src/TopLevelConstructorTwiceTest.elm

This file defines multiple `C` type constructors. One here:

22|     = C String
          ^
And another one here:

18|     = C Int
          ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- NAME CLASH ----------------------------- src/TopLevelConstructorTwiceTest.elm

This file defines multiple `C` type constructors. One here:

22|     = C String
          ^
And another one here:

18|     = C Int
          ^
How can I know which one you want? Rename one of them!

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- NAME CLASH ----------------------------- src/TopLevelConstructorTwiceTest.elm

This file defines multiple `C` type constructors. One here:

22|     = C String
          ^
And another one here:

18|     = C Int
          ^
How can I know which one you want? Rename one of them!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module TopLevelConstructorTwiceTest exposing (main)
{-| Two custom types may not declare the same constructor.
A Standard Definition of Elm?, restriction modules-constructors-distinct: no module may declare the
same constructor twice. <https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>
-}
-- TAGS: elm-spec, modules-constructors-distinct
-- COMPILE-ERROR: a constructor declared by two types
-- CHECK: {{-- [A-Z ]+ -}}
import Html
type A
= C Int
type B
= C 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_TopLevelConstructorTwiceTest, 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-constructors-distinct. It holds for every derivation, with no hypothesis about principality.