# S2 - a wrapper around version 2 of erlang sets

**URL:** <https://erlangforums.com/t/s2-a-wrapper-around-version-2-of-erlang-sets/4394>\
**Category:** Libraries\
**Tags:** erlang, s2\
**Created:** [January 16, 2025, 1:45pm UTC](https://erlangforums.com/t/s2-a-wrapper-around-version-2-of-erlang-sets/4394 "2025-01-16T13:45:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chiroptical](https://erlangforums.com/user_avatar/erlangforums.com/chiroptical/32/2044_2.png) [@chiroptical](https://erlangforums.com/u/chiroptical)\
**Post date:** [January 16, 2025, 1:45pm UTC](https://erlangforums.com/t/s2-a-wrapper-around-version-2-of-erlang-sets/4394/1 "2025-01-16T13:45:32Z")

</div>

Good morning, while working through advent of code this year in Erlang, sets come up A LOT. I was experimenting with erlang-language-platform and it kept yelling at me about constructing sets using the `{version, 2}` option. According to [sets — stdlib v6.2](https://www.erlang.org/doc/apps/stdlib/sets.html) a new internal representation was available (“version 2”) in OTP 24 and is more performant.

I like performance! I am also lazy and forgetful 😄. So, I just made a light wrapper around it called s2. The documentation can be found at [s2 — s2 v1.0.0](https://hexdocs.pm/s2/s2.html). The code can be found at [GitHub - chiroptical/s2: A facade over sets](https://github.com/chiroptical/s2). The API surface is more like Haskell’s `Data.Set` library because I am more familiar it. I also added some functionality like `cartesian_product/2` and `is_proper_subset/2`. Finally, the string representation is much more readable which was useful for advent of code but probably not a deal breaker.

Even if the “version 2” internal representation is made the default across the board in OTP, my library offers a slightly different API surface which you may, or may not, like better. Do you feel like anything is missing? Feel free to send me an issue or PR!

Cheers,

Barry (aka chiroptical)
