License | MIT |
---|---|
Maintainer | mmzk1526@outlook.com |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
UUIDv7 implementation.
UUIDv7 is not currently present in the uuid package, therefore I have to make a quick patch of my own. In the future I will try to add uuid as a dependency and try to use the same interface.
Note that since the specification for v7 is not yet finalised, this module's implementation may change in the future according to the potential adjustments in the specification.
Synopsis
- newtype UUID = UUID {
- unUUID :: ByteString
- nil :: UUID
- genUUID :: IO UUID
- genUUIDs :: Word16 -> IO [UUID]
- parseString :: String -> Maybe UUID
- parseText :: Text -> Maybe UUID
- parseByteString :: ByteString -> Maybe UUID
- toString :: UUID -> String
- toText :: UUID -> Text
- toByteString :: UUID -> ByteString
- getTime :: UUID -> Word64
- getEpochMilli :: IO Word64
Data type
A simple wrapper around a ByteString
representing a UUIDv7.
Note that the Show
instance is for debugging purposes only. To pretty-print
a UUID
v7, use toString
, toText
or toByteString
.
UUID | |
|
UUID generation
Encoding & decoding
parseByteString :: ByteString -> Maybe UUID Source #
Parse a UUID
v7 from its string representation as a lazy ByteString
.
The representation is either standard or has no dashes. Does not care about the case of the letters.
toByteString :: UUID -> ByteString Source #
Pretty-print a UUID
v7 to lazy ByteString
.
Miscellaneous helpers
getEpochMilli :: IO Word64 Source #
Get the current time in milliseconds since the Unix epoch.