Created
February 18, 2012 06:03
-
-
Save bradclawsie/1857744 to your computer and use it in GitHub Desktop.
generate hashed and random uuids in haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE PackageImports #-} | |
module Main where | |
import qualified Data.Char as C | |
import qualified Data.Word as W | |
-- must qualify this (requiring the ghc pragma above) to disambiguate | |
-- from the Data.UUID also in system-uuid | |
import qualified "uuid" Data.UUID as U | |
import qualified Data.UUID.V5 as U5 | |
-- the system uuid generates using the sys random facility | |
import qualified System.UUID.V4 as U4 | |
main :: IO () | |
main = let url = map (fromIntegral . C.ord) "example.com" :: [W.Word8] | |
url_uuid = U5.generateNamed U5.namespaceDNS url in | |
print url_uuid >> U4.uuid >>= print | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment