New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is infix priority of (!) correct? #638

Closed
jinjor opened this Issue Jun 3, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@jinjor
Contributor

jinjor commented Jun 3, 2016

I tired to expand the counter example to use program instead of beginnerProgram. I added empty command in update function, and got this error message. Is this a correct behavior?

-- TYPE MISMATCH ---------------------------------------------------------------

The right argument of (+) is causing a type mismatch.

25|       model + 1 ! []
                  ^^^^^^
(+) is expecting the right argument to be a:

    number

But the right argument is:

    ( number, Cmd a )

Hint: I always figure out the type of the left argument first and if it is
acceptable on its own, I assume it is "correct" in subsequent checks. So the
problem may actually be in how the left and right arguments interact.

I assumed model + 1 should be evaluated first.

But it's trivial anyway. Adding a pair of parens fixes it.

@cobalamin

This comment has been minimized.

Show comment
Hide comment
@cobalamin

cobalamin Jul 18, 2016

Judging from http://faq.elm-community.org/operators.html, I'd say it should have a declaration of:

infixl 1 !

to work with everything up to and including ||, but still be lower precedence than |>/<|.

You can declare this in your own code somewhere, which seems a bit off to me, but it works. That declaration would break as soon as (!) gets its own associativity/precedence declaration in core, though.

cobalamin commented Jul 18, 2016

Judging from http://faq.elm-community.org/operators.html, I'd say it should have a declaration of:

infixl 1 !

to work with everything up to and including ||, but still be lower precedence than |>/<|.

You can declare this in your own code somewhere, which seems a bit off to me, but it works. That declaration would break as soon as (!) gets its own associativity/precedence declaration in core, though.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jul 10, 2017

Member

The current plan is to drop (!) but I agree that if it ends up in 0.19 it should have a very low precedence, possibly such that it'll work with (|>) chains.

Member

evancz commented Jul 10, 2017

The current plan is to drop (!) but I agree that if it ends up in 0.19 it should have a very low precedence, possibly such that it'll work with (|>) chains.

@MartinKavik

This comment has been minimized.

Show comment
Hide comment
@MartinKavik

MartinKavik May 7, 2018

Just note:
Some ideas for infix operator precedence (including !) - https://discourse.elm-lang.org/t/infix-operators-lower-precedence-than-and/1235

MartinKavik commented May 7, 2018

Just note:
Some ideas for infix operator precedence (including !) - https://discourse.elm-lang.org/t/infix-operators-lower-precedence-than-and/1235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment