module Data.UUID.V4 (nextRandom) where
import Data.UUID
import Data.UUID.Types.Internal ( buildFromBytes )
import System.Entropy ( getEntropy )
import Data.ByteString ( unpack )
nextRandom :: IO UUID
nextRandom :: IO UUID
nextRandom = do
[b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf]
<- ByteString -> [Word8]
unpack (ByteString -> [Word8]) -> IO ByteString -> IO [Word8]
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Int -> IO ByteString
getEntropy Int
16
return $ buildFromBytes 4 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf