module Data.Random.Vector(randomElement) where

import           Data.Random.RVar
import           Data.Random.Distribution.Uniform
import qualified Data.Vector  as V

-- | Take a random element of a vector.
randomElement :: V.Vector a -> RVar a
randomElement :: Vector a -> RVar a
randomElement Vector a
wrds = (Vector a
wrds Vector a -> Int -> a
forall a. Vector a -> Int -> a
V.!) (Int -> a) -> RVarT Identity Int -> RVar a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Int -> RVarT Identity Int
forall a. Distribution Uniform a => a -> a -> RVar a
uniform Int
0 (Vector a -> Int
forall a. Vector a -> Int
V.length Vector a
wrds Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)