pure-shuffle-0.1.1.1

Safe HaskellNone
LanguageHaskell2010

Algorithms.Random.Shuffle.Pure

Synopsis

Documentation

shuffle :: Monad m => GetRandR m -> [a] -> m [a] Source #

Reimplementation of shuffleM in terms of a raw Monad m => m a. TODO: Generalize by mono-traversable

sampleOne :: (IsSequence seq, Monad m) => GetRandR m -> seq -> m (Maybe (Element seq)) Source #

Implementation of Reservoir sampling for a single sample.

sampleSplitOne :: (IsSequence seq, Monad m) => GetRandR m -> seq -> m (Maybe (Element seq, seq)) Source #

Implementation of Reservoir sampling for a single sample. By contrast to sampleOne, this function returns not chosen elements in addition.

type GetRandR m = (Int, Int) -> m Int Source #

Monadic action generating an index number for shuffling. The type parameter m is usually some Monad. The first argument is a inclusive range (lo, hi). So the retuned value should be lo <= x <= hi (like randomR and uniformR).