HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulerandom-fu-0.3.0.1Haskell2010

Data.Random.Sample

  • 1 class
  • 3 values
  • Packagerandom-fu-0.3.0.1
  • Exports4
  • LanguageHaskell2010
  • LicenceLicenseRef-PublicDomain
  • SourceSample.hs
classclass Sampleable (d :: Type -> Type) (m :: Type -> Type) t where
#

A typeclass allowing Distributions and RVars to be sampled. Both may also be sampled via runRVar or runRVarT, but I find it psychologically pleasing to be able to sample both using this function, as they are two separate abstractions for one base concept: a random variable.

Methods

  • sampleFrom :: StatefulGen g m => g -> d t -> m t

    Directly sample from a distribution or random variable, using the given source of entropy.

Instances2Sampleable
valuesampleState :: (Distribution d t, RandomGen g, MonadState g m) => d t -> m t
#

Sample a random variable in a "functional" style. Typical instantiations of s are System.Random.StdGen or System.Random.Mersenne.Pure64.PureMT. sample :: (Distribution d a, StatefulGen g m, MonadReader g m) => d t -> m t sample thing gen = runStateGen gen (stateGen -> sampleFrom stateGen thing)

valuesamplePure :: (Distribution d t, RandomGen g) => d t -> g -> (t, g)
#

Sample a random variable in a "functional" style. Typical instantiations of g are System.Random.StdGen or System.Random.Mersenne.Pure64.PureMT.