What are the reserved keywords in Elm?

From time to time you get a compiler error:

It looks like the keyword `port` is being used as a variable. 

This is annoying. Is there a complete official list of these keywords? I went so far as to find where the error messages are generated , but I could not find where exactly the keywords were defined.

Meanwhile, here is probably an incomplete or incorrect list of keywords that I found by looking at the syntax page and trying the keywords in repl:

  • let be
  • in
  • Where
  • Module
  • exposing
  • of type
  • Port
  • import
  • infixr
  • in
  • if a
  • yet
  • then
+6
source share
1 answer

According to the source code of the elm compiler, the list of reserved keywords is :

 keywords = Set.fromList [ "if", "then", "else" , "case", "of" , "let", "in" , "type" , "module", "where" , "import", "exposing" , "as" , "port" ] 

Edit: Actually there are a few more keywords (found searching for β€œreserved” in the repo) I found: infix , infixl , infixr . infixr also marked OP.

+7
source

All Articles