-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |