jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
373 stars 67 forks source link

`effect` should not be considered a keyword #189

Closed ghost closed 1 year ago

ghost commented 1 year ago

Why is effect considered a keyword and highlighted as such? I can use it as a variable name and the compiler doesn't complain in elm version 0.19.

purcell commented 1 year ago

Want to fire a PR in our direction?

ghost commented 1 year ago

Sure, I can do that.

For the purposes of syntax highlighting (not parsing nor compiling), and the purpose of elm-mode, I think that it's okay to remove the keyword, other editors such as VS Code or the Ellie app don't highlight it.

Inspecting the elm compiler source code, it seems that effect actually is a keyword: https://github.com/elm/compiler/blob/master/compiler/src/Parse/Keyword.hs#L3 https://github.com/elm/compiler/blob/master/compiler/src/Parse/Module.hs#L288

But trying to use it gives the following error:

It is not possible to declare an effect module outside the @elm organization, so I am getting stuck here:

1| effect module Main where {command = MyCmd} exposing (main) ^^^^^^^^^^^^^ Switch to a normal module declaration.

Note: Effect modules are designed to allow certain core functionality to be defined separately from the compiler. So the @elm organization has access to this so that certain changes, extensions, and fixes can be introduced without needing to release new Elm binaries. For example, we want to make it possible to test effects, but this may require changes to the design of effect modules. By only having them defined in the @elm organization, that kind of design work can proceed much more smoothly.

So, in the same way that we can use alias as an identifier even though it is a keyword, and the syntax highlighters aren't smart enough to recognized when it's not used as a keyword, this would be like erring on the other side.

purcell commented 1 year ago

Fixed by #190