-- | An effect for generating random values.
-- | An effect for generating random values.
data RNG :: Effect where
GenRSA :: RNG m (RSA.PublicKey, RSA.PrivateKey)
GenUUID :: RNG m UUID
GenBytes :: Int -> RNG m BS.ByteString
type
-- | A handler for the `RNG` effect.
runRNG
:: (IOE :> es)
=> Eff (RNG : es) a
-> Eff es a
runRNG = interpret $ \_ -> \case
GenRSA -> liftIO (RSA.generate 1024 65537)
GenUUID -> liftIO UUID.nextRandom
GenBytes len -> liftIO (getRandomBytes len)
makeEffect ''RNG