Skip to content

Commit

Permalink
Announce Heptapod (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak authored Aug 18, 2024
1 parent b1e5f03 commit a865f32
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions _posts/2024-08-18-heptapod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: 'Announcing Heptapod: Generate UUIDv7 in Haskell'
---

I'm happy to announce [Heptapod][1], a tiny Haskell library for generating version 7 UUIDs.
If you're not familiar with UUIDv7s, they are defined by [RFC 9562][2].
As a brief summary, they are sort of like a mix of UUIDv1s and UUIDv4s.
They start with a timestamp and end with some randomness.
Here's a diagram of their layout:

```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| unix_ts_ms |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| unix_ts_ms | ver | rand_a |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var| rand_b |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| rand_b |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```

Heptapod allows you to generate UUIDv7s.
`unix_ts_ms` comes from [`getSystemTime`][3].
Both `rand_a` and `rand_b` both come from [`getEntropy`][4], which is cryptographically secure.

The `rand_a` field can be a few different things: additional clock precision, a monotonic counter, or simply more randomness.
Heptapod chooses the latter.
If you'd like it to be something else, Heptapod also allows you to build your own UUIDv7 using provided values for `unix_ts_ms`, `rand_a`, and `rand_b`.

That's it!
Please check out [Heptapod][1] and consider using version 7 UUIDs!

[1]: https://hackage.haskell.org/package/heptapod-1.0.0.0
[2]: https://datatracker.ietf.org/doc/html/rfc9562
[3]: https://hackage.haskell.org/package/time-1.14/docs/Data-Time-Clock-System.html#v:getSystemTime
[4]: https://hackage.haskell.org/package/entropy-0.4.1.10/docs/System-Entropy.html#v:getEntropy

0 comments on commit a865f32

Please sign in to comment.