0 | module Control.Monad.Bayes.Sampler
 1 |
 2 | import Control.Monad.Bayes.Interface
 3 | import System.Random
 4 |
 5 | ||| An 'IO' based random sampler.
 6 | public export
 7 | SamplerIO : Type -> Type
 8 | SamplerIO = IO
 9 |
10 | public export
11 | MonadSample SamplerIO where
12 |   random = System.Random.randomIO
13 |
14 | ||| Initialize a pseudo-random number generator using randomness supplied by the operating system. Providing the randomness, i.e. setting the random seed, is done automatically, so this is just `id`.
15 | public export
16 | sampleIO : SamplerIO a -> IO a
17 | sampleIO = id
18 |
19 | ||| Like 'sampleIO' but with a custom seed.
20 | public export
21 | sampleIOwith : SamplerIO a -> Bits64 -> IO a
22 | sampleIOwith m seed = srand seed >> m