File: Random.hs

package info (click to toggle)
haskell-vector 0.6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 632 kB
  • ctags: 20
  • sloc: haskell: 7,341; ansic: 23; 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