ulid-0.2.0.0: Implementation of ULID, lexicographically sortable unique identifiers

Copyright(c) 2017 Steve Kollmansberger
LicenseBSD-style
Maintainersteve@kolls.net
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.ULID

Description

This library implements the Universally Unique Lexicographically Sortable Identifier, as described at https://github.com/alizain/ulid.

UUID can be suboptimal for many uses-cases because:

  • It isn't the most character efficient way of encoding 128 bits of randomness
  • UUID v1/v2 is impractical in many environments, as it requires access to a unique, stable MAC address
  • UUID v3/v5 requires a unique seed and produces randomly distributed IDs, which can cause fragmentation in many data structures
  • UUID v4 provides no other information than randomness which can cause fragmentation in many data structures

Instead, herein is proposed ULID:

  • 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)

Synopsis

Documentation

data ULID Source #

Constructors

ULID 

Instances

Eq ULID Source # 

Methods

(==) :: ULID -> ULID -> Bool #

(/=) :: ULID -> ULID -> Bool #

Data ULID Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ULID -> c ULID #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ULID #

toConstr :: ULID -> Constr #

dataTypeOf :: ULID -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ULID) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ULID) #

gmapT :: (forall b. Data b => b -> b) -> ULID -> ULID #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ULID -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ULID -> r #

gmapQ :: (forall d. Data d => d -> u) -> ULID -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ULID -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ULID -> m ULID #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ULID -> m ULID #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ULID -> m ULID #

Ord ULID Source # 

Methods

compare :: ULID -> ULID -> Ordering #

(<) :: ULID -> ULID -> Bool #

(<=) :: ULID -> ULID -> Bool #

(>) :: ULID -> ULID -> Bool #

(>=) :: ULID -> ULID -> Bool #

max :: ULID -> ULID -> ULID #

min :: ULID -> ULID -> ULID #

Read ULID Source # 
Show ULID Source # 

Methods

showsPrec :: Int -> ULID -> ShowS #

show :: ULID -> String #

showList :: [ULID] -> ShowS #

Binary ULID Source # 

Methods

put :: ULID -> Put #

get :: Get ULID #

putList :: [ULID] -> Put #

NFData ULID Source # 

Methods

rnf :: ULID -> () #

Hashable ULID Source # 

Methods

hashWithSalt :: Int -> ULID -> Int #

hash :: ULID -> Int #

Random ULID Source # 

Methods

randomR :: RandomGen g => (ULID, ULID) -> g -> (ULID, g) #

random :: RandomGen g => g -> (ULID, g) #

randomRs :: RandomGen g => (ULID, ULID) -> g -> [ULID] #

randoms :: RandomGen g => g -> [ULID] #

randomRIO :: (ULID, ULID) -> IO ULID #

randomIO :: IO ULID #

getULIDTime Source #

Arguments

:: POSIXTime

The specified UNIX time (seconds) to millisecond precision, e.g. 1469918176.385

-> IO ULID 

Derive a ULID using a specified time and default random number generator

getULID :: IO ULID Source #

Derive a ULID using the current time and default random number generator

ulidToInteger :: ULID -> Integer Source #

Convert a ULID to its corresponding (at most) 128-bit Integer. Integer equivalents retain sortable trait (same sort order). This could be useful for storing in a database using a smaller field than storing the Show'n string, but still human-readable unlike the Binary version.

ulidFromInteger Source #

Arguments

:: Integer

The ULID's Integer equivalent, as generated by toInteger

-> ULID 

Convert a ULID from its corresponding 128-bit Integer.