gini-core-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Gini.Core.Util

Description

General utilities used throughout the Gini codebase.

Synopsis

Documentation

atomicallyWithEnv :: (MonadIO m, MonadReader env m) => ReaderT env STM a -> m a #

Run an STM action with the same ReaderT environment as the calling RIO environment.

periodically :: MonadIO m => NominalDiffTime -> (UTCTime -> m ()) -> m () #

Periodically run an action. Note that this will not run the actions in parallel, so only works for finite actions. If the action takes longer than the period, it will be run again immediately.

randomSample :: Int -> [a] -> StdGen -> ([a], StdGen) #

Take a random sample of elements from the list. If the requested number of elements is >= the length of the list, then the whole list is returned. IMPORTANT: not for cryptographically secure use!