ImportClosedTypeConstructorTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:rule sm-item-typerule s-atexp-longconrule dm-expitem-type
Not translated into Lean for the mechanisation of the book: see why.
A custom type exposed without `(..)` exposes no constructor, even one spelt as the type. A Standard Definition of Elm?, rules sm-item-type and dm-expitem-type: `ModuleExposingHelper` exposes `Shape` closed, so `import ModuleExposingHelper exposing (Shape)` imports the type `Shape` and not its constructor `Shape`. <https://elm-test-suite.netlify.app/standard/rules/dm-expitem-type>
Results
elm-0.19.1
passOutput
Compiling ...-- NAMING ERROR ------------------------ src/ImportClosedTypeConstructorTest.elm
I cannot find a `Shape` variant:
22| Debug.log "shape" (ModuleExposingHelper.unwrapShape (Shape 1))
^^^^^
These names seem close though:
False
True
EQ
Err
Hint: Read <https://elm-lang.org/0.19.1/imports> to see how `import`
declarations work in Elm.
Detected problems in 1 module.
elm-0.19.2
passOutput
Compiling ...-- NAMING ERROR ------------------------ src/ImportClosedTypeConstructorTest.elm
I cannot find a `Shape` variant:
22| Debug.log "shape" (ModuleExposingHelper.unwrapShape (Shape 1))
^^^^^
These names seem close though:
False
True
EQ
Err
Hint: Read <https://elm-lang.org/0.19.2/imports> to see how `import`
declarations work in Elm.
Detected problems in 1 module.
elm-0.19.3
passOutput
Compiling ...-- NAMING ERROR ------------------------ src/ImportClosedTypeConstructorTest.elm
I cannot find a `Shape` variant:
22| Debug.log "shape" (ModuleExposingHelper.unwrapShape (Shape 1))
^^^^^
These names seem close though:
True
False
EQ
GT
Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.
Detected problems in 1 module.
lamdera-1.5.0
passOutput
Detected problems in 1 module.
-- NAMING ERROR ------------------------ src/ImportClosedTypeConstructorTest.elm
I cannot find a `Shape` variant:
22| Debug.log "shape" (ModuleExposingHelper.unwrapShape (Shape 1))
^^^^^
These names seem close though:
True
False
EQ
GT
Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm/ImportClosedTypeConstructorTest] in its title.
Source
The -- CHECK: lines give the expected output.
module ImportClosedTypeConstructorTest exposing (main)
{-| A custom type exposed without `(..)` exposes no constructor, even one spelt as the type.
A Standard Definition of Elm?, rules sm-item-type and dm-expitem-type: `ModuleExposingHelper`
exposes `Shape` closed, so `import ModuleExposingHelper exposing (Shape)` imports the type
`Shape` and not its constructor `Shape`. <https://elm-test-suite.netlify.app/standard/rules/dm-expitem-type>
-}
-- TAGS: elm-spec, sm-item-type, s-atexp-longcon, dm-expitem-type
-- COMPILE-ERROR: a use of a constructor of a type exposed closed
-- CHECK: {{-- [A-Z ]+ -}}
import Html
import ModuleExposingHelper exposing (Shape)
main =
let
_ =
Debug.log "shape" (ModuleExposingHelper.unwrapShape (Shape 1))
in
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_ImportClosedTypeConstructorTest, in StandardElmMech/Certs/). A name is out of scope (or a constructor pattern has the wrong arity) in every derivation (Stat.not_legal_of_scopeFailB). It holds for every derivation, with no hypothesis about principality.