Elm Exactly
Results / elm /

InfixNonAssocCompareTest

Tags:elm-spec

Checks, in A Standard Definition of Elm?:restriction core-operator-chainfigure core-fixities

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 < b == c` is not a phrase: `<` and `==` have equal precedence and associate neither way.

A Standard Definition of Elm?, restriction core-operator-chain: two operators of equal
precedence with no operator of lower precedence between them must both associate to the left
or both to the right; otherwise the chain is not a phrase of the language. <https://elm-test-suite.netlify.app/standard/restrictions/core-operator-chain>

The book's example. The error must be the chain's, not a type error.

Results

elm-0.19.1

pass
Output
Compiling ...-- INFIX PROBLEM ------------------------------ src/InfixNonAssocCompareTest.elm

You cannot mix (<) and (==) without parentheses.

22|     Html.text (Debug.toString (1 < 2 == True))
                                   ^^^^^^^^^^^^^
I do not know how to group these expressions. Add parentheses for me!

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- INFIX PROBLEM ------------------------------ src/InfixNonAssocCompareTest.elm

You cannot mix (<) and (==) without parentheses.

22|     Html.text (Debug.toString (1 < 2 == True))
                                   ^^^^^^^^^^^^^
I do not know how to group these expressions. Add parentheses for me!

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- INFIX PROBLEM ------------------------------ src/InfixNonAssocCompareTest.elm

You cannot mix (<) and (==) without parentheses.

22|     Html.text (Debug.toString (1 < 2 == True))
                                   ^^^^^^^^^^^^^
I do not know how to group these expressions. Add parentheses for me!

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- INFIX PROBLEM ------------------------------ src/InfixNonAssocCompareTest.elm

You cannot mix (<) and (==) without parentheses.

22|     Html.text (Debug.toString (1 < 2 == True))
                                   ^^^^^^^^^^^^^
I do not know how to group these expressions. Add parentheses for me!

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module InfixNonAssocCompareTest exposing (main)
{-| `a < b == c` is not a phrase: `<` and `==` have equal precedence and associate neither way.
A Standard Definition of Elm?, restriction core-operator-chain: two operators of equal
precedence with no operator of lower precedence between them must both associate to the left
or both to the right; otherwise the chain is not a phrase of the language. <https://elm-test-suite.netlify.app/standard/restrictions/core-operator-chain>
The book's example. The error must be the chain's, not a type error.
-}
-- TAGS: elm-spec, core-operator-chain, fig:core-fixities
-- COMPILE-ERROR: two non-associative operators of equal precedence
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: TYPE MISMATCH
import Html
main =
Html.text (Debug.toString (1 < 2 == True))

Lean translation

No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Static semantics: expected to be rejected, and the translator's front end refuses it: it breaks a restriction on characters, tokens and layout, which Lean does not model. See the Lean mechanisation for which tests are in Lean, and why.