rando-0.0.0.2: src/System/Random/Pick.hs
module System.Random.Pick (
pickOne
, flipCoin
) where
import System.Random.TF.Init
import System.Random.TF.Instances
pickOne :: [x] -> IO x
pickOne l = do
g <- newTFGen
let (ix, _) = randomR (0, (length::[a]->Int) l - 1) g
pure $ l !! ix
flipCoin :: IO Bool
flipCoin = pickOne [True, False]