Intellij-elm 2.0: Infer the type of Elm expressions directly within the editor


#1

This morning we released version 2.0 of intellij-elm with a major new feature: the Elm type system is now modeled directly within the editor plugin. This allows the plugin to understand the types of your Elm functions, values, and expressions, enabling some cool features:

New Features

Infer Type of Expression

Show the inferred type of any Elm expression. Press Ctrl-Shift-P to see the type of the expression under the cursor, or expand the selection to include parent expressions. demo video (11 seconds)

Type Checking

Type mismatches are detected and shown directly within the editor. For instance, if you try to call a function that expects a String but you give it a Char , an error will be shown on the bad argument. The type checking is performed immediately within the plugin—no need to wait for the Elm compiler to be launched in an external process. demo video (8 seconds)

Questions

What is IntelliJ?

IntelliJ is a powerful and free IDE built on a unique architecture. Rather than working with source code in its text form, IntelliJ parses the source code into an abstract syntax tree (AST). All functionality and refactorings are built on this AST, allowing for much more sophisticated features than normally possible in a text editor that relies on regex and find/replace.

IntelliJ comes in many flavors including the free Community Edition, WebStorm (for web devs), PyCharm (for Python devs), etc.

What is intellij-elm?

intellij-elm is an Elm language plugin for IntelliJ that I wrote in collaboration with one of my co-workers, AJ Alt. It is:

  • compatibile with both Elm 0.19 and 0.18
  • has built-in support for code-completion, go-to-declaration, rename support and much more
  • it reads your elm.json and elm-package.json files to understand your project’s dependencies, source-dirs etc.
  • it works with IntelliJ, WebStorm, PyCharm, etc.
  • it is free

More info—including demo videos of unique/advanced features—can be found on the project website.

Current Limitations

  • we haven’t yet added support for parameterized Elm types (those with a type variable like List a)
  • we currently rely on functions having type annotations.

Future

Having the type system modeled within the Elm editor plugin will allow some advanced refactorings and other features. Some of you may have seen Ravi Chugh’s elm-conf 2018 talk on structured editing. Many of these types of program transformations will be possible within a familiar text-based IDE.


#2

Very cool, support for Elm in IDEA has come a long way since last year! Thanks for all your work!

Just as a pointer, you may be interested in Presentation Assistant for recording those videos.


#3

I didn’t know about Presentation Assistant. Nice!


#4

Thank you for your hard work.


#5

I browsed through the code, especially the type inference part. The amount of work put into this is staggering. Great work. I hope we had such good plugins for other editors as well (emacs user here)