🍐 Elm-pair

Elm-pair helps you write Elm code. You tell Elm-pair about the change you want to make and it will do the actual work. It's a bit like using an IDE except you don't need to learn any keyboard shortcuts.

You talk to Elm-pair by making a change in your code and saving it. Elm-pair will notice the change you made, and if it understands your intent will respond with a change off its own.

To explain what working with Elm-pair is like its easiest to show you some examples. In the recordings below we use the terminal editor Vim, but Elm-pair runs on any editor that supports the editor-driver protocol.

Usage

Changing names

Change the name of a type in one place and Elm-pair will find all other uses of the type across your project and rename them too. This doesn't just work for renaming types, but for functions, let bindings, constructors, and record fields too!

Renaming a type
Renaming a record field

Working with imports

Elm-pair manages your list of module imports. Start using a function from another module and Elm-pair will add an import for it. Stop using a module and Elm-pair will remove its import.

Add an import
Add an import to the exposing list
Remove an unused import

Changing functions

Add or remove functions to an argument and Elm-pair will change all places the function is used to ensure your project keeps compiling.

Add an argument to function
Remove an argument from a function

Extracting and inlining code

Elm-pair helps you break a up complex code into pieces. You can start by removing part of a larger Elm expression, and make up a name for a yet-to-be-written helper function to replace it with. Elm-pair will respond by creating the helper in a let statement. If you want you can turn the newly created helper into a top level function. If the helper body now uses values that are no longer in scope Elm-pair will add arguments for them.

Sometimes we get carried away with breaking code up. To make sense of it we need to move it together again. No problem. Just remove the helper function you no longer want and Elm-pair will inline its body everywhere the helper was used.

Extract code into a let
Turning a let into a top level function
Inlining a helper by removing it

Evolving types

As an application grows so do the applications types. A primitive `Int` might be replaced with a wrapper type `Id` or a record might gain additional fields. Whenever you initiate a change like this Elm-pair will finish it for you and keep your code compiling.

Replace a primitive type with a type alias
Upgrade a type alias to a wrapper type
Add a new field to a record

Will Elm-pair break my code?

You might worry about Elm-pair breaking your code, requiring you to clean up after it. That could cost you more time than you save!

To prevent mistakes Elm-pair responds to a change you make with a change off its own if your Elm project compiles afterwards. If Elm-pair cannot make a change that will get your project to compile it will do nothing.

This makes Elm-pair the perfect companion for 'type driven development'. This style of programming is about taking small steps, ensuring your code compiles after each step. If you dislike this style of programming Elm-pair might not be the right tool for you.

Get it!

I'm really sorry to say Elm-pair doesn't exist yet. It's just an idea, and the recordings on this page have all been faked. I wrote up some additional thoughts on a possible architecture for Elm-pair in a blog post on improvig language servers.

I'd love to hear your thoughts on Elm-pair. Would it support you working with Elm or not? Would you prefer Elm-pair over more classical IDE-like functions that you trigger explicitly? Please let me know on Elm Discourse, dev.to, or Twitter. And maybe some day a tool like Elm-pair will have our back!