File: Random.hs

package info (click to toggle)
haskell-vector 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 816 kB
  • sloc: haskell: 8,809; ansic: 13; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 386 bytes parent folder | download | duplicates (5)
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