uuid-1.2.3: For creating, comparing, parsing and printing Universally Unique Identifiers

Portability | portable
Stability | experimental
Maintainer | aslatter@gmail.com
Safe Haskell | Safe-Inferred

Data.UUID

Description

This library is useful for comparing, parsing and printing Universally Unique Identifiers. See http://en.wikipedia.org/wiki/UUID for the general idea. See http://tools.ietf.org/html/rfc4122 for the specification.

For generating UUIDs, check out `V1`, `V5` and `Random`.

Synopsis

- data UUID
- toString :: UUID -> String
- fromString :: String -> Maybe UUID
- toByteString :: UUID -> ByteString
- fromByteString :: ByteString -> Maybe UUID
- toWords :: UUID -> (Word32, Word32, Word32, Word32)
- fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
- null :: UUID -> Bool
- nil :: UUID

# Documentation

data UUID Source

The UUID type. A `Random` instance is provided which produces version 4 UUIDs as specified in RFC 4122. The `Storable` and `Binary` instances are compatible with RFC 4122, storing the fields in network order as 16 bytes.

Instances

Eq UUID |
Data UUID |
Ord UUID |
Read UUID |
Show UUID |
Typeable UUID |
Storable UUID |
Binary UUID |
Random UUID |

toString :: UUID -> String Source

Convert a UUID into a hypenated string using lower-case letters. Example:

      toString $ fromString "550e8400-e29b-41d4-a716-446655440000"

fromString :: String -> Maybe UUID Source

If the passed in `String` can be parsed as a `UUID`, it will be. The hyphens may not be omitted. Example:

      fromString "c2cc10e1-57d6-4b6f-9899-38d972112d8c"

Hex digits may be upper or lower-case.

toByteString :: UUID -> ByteString Source

Encode a UUID into a `ByteString` in network order.

fromByteString :: ByteString -> Maybe UUID Source

Extract a UUID from a `ByteString` in network byte order. The argument must be 16 bytes long, otherwise `Nothing` is returned.

toWords :: UUID -> (Word32, Word32, Word32, Word32)Source

Covert a `UUID` into a sequence of `Word32` values. Usefull for when you need to serialize a UUID and neither `Storable` nor `Binary` are appropriate.

fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID Source

Create a `UUID` from a sequence of `Word32`. The opposite of `toWords`.

null :: UUID -> Bool Source

Returns true if the passed-in UUID is the `nil` UUID.

nil :: UUID Source

The nil UUID, as defined in RFC 4122. It is a UUID of all zeros. ``null` u` iff ``u` == `nil``.