evancz/elm-architecture-tutorial

01-button.elm has syntax errors

vlvagerviwager opened this issue · 5 comments

When I try to compile the Buttons example, I get this:

$ sudo elm-make Buttons.elm --output=Buttons.html
-- SYNTAX PROBLEM -------------------------------------------------- Buttons.elm

The = operator is reserved for defining variables. Maybe you want == instead? Or
maybe you are defining a variable, but there is whitespace before it?

32|       model = 0
                ^
Maybe <http://elm-lang.org/docs/syntax> can help you figure it out.

Detected errors in 1 module.                                        

When I open the example in the online editor, it's different and compiles. Maybe the example on the page is not intended to be copied verbatim and compiled?

Apologies if I am misunderstanding something, I am a complete Elm beginner.

  • OS: macOS Sierra 10.12.4
  • Elm version: 0.18.0

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@zky829 Could you post or point to the code (the copied one on your machine)? It'd be clear if we see the copied code. The error message is obvious though.

sr-ix commented

I am assuming you are doing the exercise in the Elm Guide to implement "Reset". You are attempting to redefine the value of model.

Try this instead:

...
    Reset ->
      model - model

Also works:

...
    Reset ->
      0

It looks like @sr-ix has a good theory of the root cause here. The example works for me, so I am not able to reproduce with the information here.