Watching Making Impossible States Impossible and reading Higher Level Coding with Elm Union Types were enlightening in my Elm development. Now, I look for places were I can refine my data model by using union types. Union types allow me to replace conditionals with pattern matching case statements. This pattern is much cleaner and easier to understand. The following is an example of how I used union types to refactor a hamburger.
It is easier to reason about Hamburger with Open and Closed types than checking against a Bool. Pattern matching on the union type is expressive and is really helpful when the union types grow in complexity.