Functional Sets, Part 9: Wrap-up

Elm 0.18 · Updated February 11, 2018 · 2 Minute Read · ∞ Permalink

Our Set implementation is done! We just have a few things to wrap up.

Get All the Posts

This was a long series! If you’d like to go through it again, or didn’t see all of the posts the first time, I’ve set up a way to get them by email. You’ll get them spaced out for easy digestion. Sign up at the bottom of this page, or any other of the series footers.

Write Your Own Dict

There’s another fun experiment you can do now: build Dict on top of what we’ve already got!

Dicts are sets of keys associated with values. In fact, core’s Set is actually Dict comparable (). All the Set functions there are wrappers over the Dict functions.

Since we’ve already got key management, you’ll just need to write some code to retrieve values. Core’s Dict implementation will be a great reference (although it uses red/black trees instead of AVL trees.) Here’s how you can change the Set constructors to get started:

type Dict comparable a
    = Tree Int comparable a (Dict comparable a) (Dict comparable a)
    | Empty


Finally, thanks so much for sticking with the series as we worked through how to build a set! Drop me a line at with any feedback, or to let me know what you’d like to see next!