Skip to content

Instantly share code, notes, and snippets.

@bradclawsie
Created February 18, 2012 06:03
Show Gist options
  • Save bradclawsie/1857744 to your computer and use it in GitHub Desktop.
Save bradclawsie/1857744 to your computer and use it in GitHub Desktop.
generate hashed and random uuids in haskell
{-# 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