Elm Exactly
Results / elm /

InfixMixedAssocPipesTest

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 |> f <| b` is not a phrase: `|>` and `<|` have equal precedence and associate in opposite ways.

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>

`1 |> (+) <| 2` would type grouped either way, and give 3 either way.

Results

elm-0.19.1

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

You cannot mix (|>) and (<|) without parentheses.

24|             Debug.log "piped" (1 |> (+) <| 2)
                                   ^^^^^^^^^^^^^
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/InfixMixedAssocPipesTest.elm

You cannot mix (|>) and (<|) without parentheses.

24|             Debug.log "piped" (1 |> (+) <| 2)
                                   ^^^^^^^^^^^^^
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/InfixMixedAssocPipesTest.elm

You cannot mix (|>) and (<|) without parentheses.

24|             Debug.log "piped" (1 |> (+) <| 2)
                                   ^^^^^^^^^^^^^
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/InfixMixedAssocPipesTest.elm

You cannot mix (|>) and (<|) without parentheses.

24|             Debug.log "piped" (1 |> (+) <| 2)
                                   ^^^^^^^^^^^^^
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/InfixMixedAssocPipesTest] in its title.

Source

The -- CHECK: lines give the expected output.

module InfixMixedAssocPipesTest exposing (main)
{-| `a |> f <| b` is not a phrase: `|>` and `<|` have equal precedence and associate in opposite ways.
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>
`1 |> (+) <| 2` would type grouped either way, and give 3 either way.
-}
-- TAGS: elm-spec, core-operator-chain, fig:core-fixities
-- COMPILE-ERROR: a left and a right associative operator of equal precedence
-- CHECK: {{-- [A-Z ]+ -}}
-- CHECK-NOT: TYPE MISMATCH
import Html
main =
let
_ =
Debug.log "piped" (1 |> (+) <| 2)
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. 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.