Data Modeling Resources in Elm

Joël Quenneville

I get a lot of requests about data modeling resources in Elm. I’ve written and spoken extensively on the topic as well as collected material from around the community. Over time, I’ve accumulated a list of links to various articles and talks that I share with people. Here is that list, made public, along with some brief commentary.

Elm logo with the words "+ data modeling"

All about types

Most data modeling in Elm is done using its excellent type system. These articles explain various aspects of the type system and the tools that it gives you for modeling.

Eliminating impossible states

🎥Making Impossible States Impossible is one of the defining talks of the Elm community. Richard Feldman showcases some simple type design tricks that make it impossible to even represent invalid states. This approach is at the heart of a lot of domain modeling in Elm. The official Elm guide has an appendix on ✍Types as Sets that digs into the more theoretical ideas of why this works.

Other resources on this topic include:


Elm comes with many primitive types such as Bool, Maybe, and Int. While these have their place, it’s easy to overuse them - a code smell known as primitive obsession. In many cases, it’s better to model domain concepts with a richer value using a custom type.

Using the compiler to check for invariants

Business systems are full of invariants. Many of these can be encoded into a program’s type system such that the compiler prevents you from writing code that breaks certain rules. Nifty!

Type Narrowing

Often in a system, entities will start as permissive, loosely formed data and progress to a stricter more well-defined entity. Modeling this journey in the type system is often called type narrowing. The canonical resource on the topic is Alexis King’s ✍Parse, Don’t Validate.

This can take an incremental approach as explored in ✍A Broader Take on Parsing where an application is modeled as a series of layers and each time data moves up one of the layers, its type gets narrowed.

General domain modeling

Still looking for more domain modeling ideas? These resources explore the general concept of domain modeling. You might come away with some new perspectives!