@@ -19,7 +19,7 @@ Original implementation and spec: [github.com/alizain/ulid]
1919```
2020
2121
22- # Universally Unique Lexicographically Sortable Identifier
22+ ## Universally Unique Lexicographically Sortable Identifier
2323
2424UUID can be suboptimal for many uses-cases because:
2525
@@ -46,6 +46,19 @@ Instead, herein is proposed ULID:
4646[ Douglas Crockford's base 32 ] : https://www.crockford.com/base32.html
4747
4848
49+ ## Known Issues
50+
51+ - No monotonicity guarantees
52+ ([ official spec] (
53+ https://github.com/ulid/spec?tab=readme-ov-file#monotonicity ))
54+ - Lexicographically sorted based on the random component
55+ if timestamps are the same.
56+ This causes the sort order to be non-deterministic
57+ for ULIDs with the same timestamp,
58+ but is necessary to avoid [ incorrect ` Map ` and ` Set ` behavior] (
59+ https://github.com/haskell-github-trust/ulid/issues/15#issuecomment-2426847267 ).
60+
61+
4962## Usage
5063
5164A simple usage example:
@@ -72,7 +85,7 @@ However, the programmer must manage the generator on their own.
7285
7386Example:
7487
75- ```` haskell
88+ ``` haskell
7689module Main where
7790
7891import Data.ULID
@@ -83,21 +96,18 @@ import qualified Data.ULID.TimeStamp as TS
8396
8497main :: IO ()
8598main = do
86- -- This default instantiation may not be sufficiently secure.
87- -- See the docs at
88- -- hackage.haskell.org/package/crypto-api-0.13.2/docs/Crypto-Random.html
8999 g <- (CR. newGenIO :: IO CR. SystemRandom )
90100
91101 -- Generate timestamp from current time
92102 t <- TS. getULIDTimeStamp
93103
94104 let ulid3 = case UR. mkCryptoULIDRandom g of
95- Left err -> error $ show err
96- -- use g2, …, to continue generating secure ULIDs
97- Right (rnd, g2) -> ULID t rnd
105+ Left err -> error $ show err
106+ -- Use g2, …, to continue generating secure ULIDs
107+ Right (rnd, g2) -> ULID t rnd
98108
99109 print ulid3
100- ````
110+ ```
101111
102112
103113## Test Suite
0 commit comments