2-- Module : Data.UUID.Named
3-- Copyright : (c) 2008 Antoine Latter
7-- Maintainer : aslatter@gmail.com
8-- Stability : experimental
9-- Portability : portable
12-- This module implements Version 3/5 UUIDs as specified
15-- These UUIDs identify an object within a namespace,
16-- and are deterministic.
18-- The namespace is identified by a UUID. Several sample
19-- namespaces are enclosed.
29import Data.UUID.Internal
31import Control.Applicative ((<*>),(<$>))
32import Data.Binary.Get (runGet, getWord32be)
34import Data.Word (Word8)
36import qualified Data.ByteString as B
37import qualified Data.ByteString.Lazy as BL
39-- |Generate a 'UUID' within the specified namespace out of the given
41generateNamed :: (B.ByteString -> B.ByteString) -- ^Hash
46generateNamed hash version namespace object =
47 let chunk = B.pack $ toList namespace ++ object
48 bytes = BL.fromChunks . (:[]) $ hash chunk
50 unpackBytes = runGet $
51 buildFromWords version <$> w <*> w <*> w <*> w
55unsafeFromString :: String -> UUID
56unsafeFromString = fromJust . fromString
58-- |The namespace for DNS addresses
60namespaceDNS = unsafeFromString "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
62-- |The namespace for URLs
64namespaceURL = unsafeFromString "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
66-- |The namespace for ISO OIDs
68namespaceOID = unsafeFromString "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
70-- |The namespace for X.500 DNs
72namespaceX500 = unsafeFromString "6ba7b814-9dad-11d1-80b4-00c04fd430c8"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list