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

Copyright | (c) 20082012 Antoine Latter
License | BSD-style
Maintainer | aslatter@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

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.

- Use `nextRandom` to generate secure random UUIDs, and your favorite instance of `Random` for faster but insecure generation of UUIDs.
- We have an implementation of generating a UUID from the hardware MAC address and current system time in Data.UUID.V1.
- For name-based generation of UUIDs using SHA-1 hashing see Data.UUID.V5.

Synopsis

- data UUID
- toString :: UUID -> String
- fromString :: String -> Maybe UUID
- toText :: UUID -> Text
- fromText :: Text -> Maybe UUID
- toASCIIBytes :: UUID -> ByteString
- fromASCIIBytes :: ByteString -> Maybe UUID
- toLazyASCIIBytes :: UUID -> ByteString
- fromLazyASCIIBytes :: ByteString -> Maybe UUID
- toByteString :: UUID -> ByteString
- fromByteString :: ByteString -> Maybe UUID
- toWords :: UUID -> (Word32, Word32, Word32, Word32)
- fromWords :: Word32 -> Word32 -> Word32 -> Word32 -> UUID
- toWords64 :: UUID -> (Word64, Word64)
- fromWords64 :: Word64 -> Word64 -> UUID
- null :: UUID -> Bool
- nil :: UUID

# Documentation

data UUID Source #

Type representing Universally Unique Identifiers (UUID) as specified in RFC 4122.

#### Instances

Instances details

Data UUID |

Instance details

Defined in Data.UUID.Types.Internal

Methods

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

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

toConstr :: UUID -> Constr Source #

dataTypeOf :: UUID -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Storable UUID | This `Storable` instance uses the memory layout as described in RFC 4122, but in contrast to the `Binary` instance, the fields are stored in host byte order.

Instance details

Defined in Data.UUID.Types.Internal

Methods

sizeOf :: UUID -> Int Source #

alignment :: UUID -> Int Source #

peekElemOff :: Ptr UUID -> Int -> IO UUID Source #

pokeElemOff :: Ptr UUID -> Int -> UUID -> IO () Source #

peekByteOff :: Ptr b -> Int -> IO UUID Source #

pokeByteOff :: Ptr b -> Int -> UUID -> IO () Source #

peek :: Ptr UUID -> IO UUID Source #

poke :: Ptr UUID -> UUID -> IO () Source #

Read UUID |
Instance details Defined in Data.UUID.Types.Internal Methods readsPrec :: Int -> ReadS UUID Source # readList :: ReadS [UUID] Source # readPrec :: ReadPrec UUID Source # readListPrec :: ReadPrec [UUID] Source #

Show UUID

Pretty prints a `UUID` (without quotation marks). See also `toString`.

    >>> show nil
    "00000000-0000-0000-0000-000000000000"

Instance details Defined in Data.UUID.Types.Internal Methods showsPrec :: Int -> UUID -> ShowS Source # show :: UUID -> String Source # showList :: [UUID] -> ShowS Source #
Binary UUID | This `Binary` instance is compatible with RFC 4122, storing the fields in network order as 16 bytes.
Instance details Defined in Data.UUID.Types.Internal Methods put :: UUID -> Put Source # get :: Get UUID Source # putList :: [UUID] -> Put Source #
NFData UUID |
Instance details Defined in Data.UUID.Types.Internal Methods rnf :: UUID -> () Source #
Eq UUID |
Instance details Defined in Data.UUID.Types.Internal Methods (==) :: UUID -> UUID -> Bool Source # (/=) :: UUID -> UUID -> Bool Source #
Ord UUID |
Instance details Defined in Data.UUID.Types.Internal Methods compare :: UUID -> UUID -> Ordering Source # (<) :: UUID -> UUID -> Bool Source # (<=) :: UUID -> UUID -> Bool Source # (>) :: UUID -> UUID -> Bool Source # (>=) :: UUID -> UUID -> Bool Source # max :: UUID -> UUID -> UUID Source # min :: UUID -> UUID -> UUID Source #
Hashable UUID |
Instance details Defined in Data.UUID.Types.Internal Methods hashWithSalt :: Int -> UUID -> Int hash :: UUID -> Int
Random UUID | This `Random` instance produces insecure version 4 UUIDs as specified in RFC 4122.
Instance details Defined in Data.UUID.Types.Internal Methods randomR :: RandomGen g => (UUID, UUID) -> g -> (UUID, g) Source # random :: RandomGen g => g -> (UUID, g) Source # randomRs :: RandomGen g => (UUID, UUID) -> g -> [UUID] Source # randoms :: RandomGen g => g -> [UUID] Source #
Uniform UUID |
Instance details Defined in Data.UUID.Types.Internal Methods uniformM :: StatefulGen g m => g -> m UUID Source #
Lift UUID |
Instance details Defined in Data.UUID.Types.Internal Methods lift :: Quote m => UUID -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => UUID -> Code m UUID Source #

toString :: UUID -> String Source #

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

    >>> toString <$> fromString "550e8400-e29b-41d4-a716-446655440000"
    Just "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"
    Just c2cc10e1-57d6-4b6f-9899-38d972112d8c

Hex digits may be upper or lower-case.

toText :: UUID -> Text Source #

Convert a UUID into a hyphentated string using lower-case letters.

fromText :: Text -> Maybe UUID Source #

If the passed in `Text` can be parsed as an ASCII representation of a `UUID`, it will be. The hyphens may not be omitted.

toASCIIBytes :: UUID -> ByteString Source #

Convert a UUID into a hyphentated string using lower-case letters, packed as ASCII bytes into `ByteString`.

This should be equivalent to `toString` with `pack`.

fromASCIIBytes :: ByteString -> Maybe UUID Source #

If the passed in `ByteString` can be parsed as an ASCII representation of a `UUID`, it will be. The hyphens may not be omitted.

This should be equivalent to `fromString` with `unpack`.

toLazyASCIIBytes :: UUID -> ByteString Source #

Similar to `toASCIIBytes` except we produce a lazy `ByteString`.

fromLazyASCIIBytes :: ByteString -> Maybe UUID Source #

Similar to `fromASCIIBytes` except parses from a lazy `ByteString`.

toByteString :: UUID -> ByteString Source #

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

This uses the same encoding as the `Binary` instance.

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 #

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

    >>> toWords <$> fromString "550e8400-e29b-41d4-a716-446655440000"
    Just (1427014656,3801825748,2803254374,1430519808)

See also `toWords64`.

Since: `uuid-1.2.2`

Since: uuid-types-1.0.0

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

Create a `UUID` from a sequence of `Word32`. The inverse of `toWords`. Useful when you need a total function for constructing `UUID` values.

See also `fromWords64`.

Since: `uuid-1.2.2`

Since: uuid-types-1.0.0

toWords64 :: UUID -> (Word64, Word64) Source #

Convert a `UUID` into a pair of `Word64`s.

    >>> toWords64 <$> fromString "550e8400-e29b-41d4-a716-446655440000"
    Just (6128981282234515924,12039885860129472512)

See also `toWords`.

Since: uuid-types-1.0.4

fromWords64 :: Word64 -> Word64 -> UUID Source #

Create a `UUID` from a pair of `Word64`s.

Inverse of `toWords64`. See also `fromWords`.

Since: uuid-types-1.0.4

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``.