package ulid

All checked builds pass
  1. Overview
  2. Docs
ULIDs for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.1.tar.gz
md5=832e5db6c4a2d1cbc67e93cf75ea484f
sha512=f9ee4d4b960e923f8a6ff81d667d3228bf18df71ca6188cc512332dd61ad6e3635ae7e08aab7c5807656be42f72a4d57540ddb2e1916dd588881253994069619

Description

ULIDs are Universally Unique Lexicographically Sortable Identifiers

Added to opam-repository:

README

ocaml-ulid

ULIDs are

  • 128-bit compatibility with UUID 1.21e+24 unique ULIDs per millisecond
  • Lexicographically sortable!
  • Canonically encoded as a 26 character string, as opposed to the 36 character UUID
  • Uses Crockford's base32 for better efficiency and readability (5 bits per character)
  • Case insensitive
  • No special characters (URL safe)
  • Monotonic sort order (correctly detects and handles the same millisecond)

See the full spec here.

This package uses nocrypto's fortuna RNG for the random part of the ULID, but a different generator can be passed in with the signature int -> int (to generate a random number between 0 and n-1).

Help is welcome!

Installation

ulid can be installed with opam:

opam install ulid

Usage

basic ulid generation:

let ulid = Ulid.ulid ();; (* something like 01D07HWDR77VCQ6CC8XSDC916T *)

passing in a seed time instead of current time (see spec for more details):

let ulid = Ulid.ulid ?seed_time:123 ();;

getting monotonic ulids:

let get_ulid = Ulid.monotonic_factory ();;
let ulid = get_ulid ();;

using a different PRNG:

let get_ulid = Ulid.ulid_factory ~prng:my_favorite_prng ();;
let ulid = get_ulid ();;

License

MIT

Dependencies (2)

  1. nocrypto
  2. dune >= "1.0.1"

Dev Dependencies (1)

  1. alcotest with-test

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building ulid with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure