-- |
-- Module      : Crypto.Random.Probabilistic
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : Good
--
module Crypto.Random.Probabilistic
    ( probabilistic
    ) where

import Crypto.Internal.Compat
import Crypto.Random.Types
import Crypto.Random

-- | This create a random number generator out of thin air with
-- the system entropy; don't generally use as the IO is not exposed
-- this can have unexpected random for.
-- 
-- This is useful for probabilistic algorithm like Miller Rabin
-- probably prime algorithm, given appropriate choice of the heuristic
--
-- Generally, it's advised not to use this function.
probabilistic :: MonadPseudoRandom ChaChaDRG a -> a
probabilistic :: forall a. MonadPseudoRandom ChaChaDRG a -> a
probabilistic MonadPseudoRandom ChaChaDRG a
f = forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall gen a. DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen)
withDRG ChaChaDRG
drg MonadPseudoRandom ChaChaDRG a
f
  where {-# NOINLINE drg #-}
        drg :: ChaChaDRG
drg = forall a. IO a -> a
unsafeDoIO forall (randomly :: * -> *).
MonadRandom randomly =>
randomly ChaChaDRG
drgNew
{-# NOINLINE probabilistic #-}