about summary refs log tree commit diff
path: root/third_party/bazel/rules_haskell/examples/vector/benchmarks/TestData/Random.hs
blob: f9b741fb97ae117a3ee97408ed700bda4aef9b33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module TestData.Random ( randomVector ) where

import qualified Data.Vector.Unboxed as V

import System.Random.MWC
import Control.Monad.ST ( runST )

randomVector :: (Variate a, V.Unbox a) => Int -> IO (V.Vector a)
randomVector n = withSystemRandom $ \g ->
  do
    xs <- sequence $ replicate n $ uniform g
    io (return $ V.fromListN n xs)
  where
    io :: IO a -> IO a
    io = id