Safe Haskell | None |
---|---|
Language | Haskell2010 |
General utilities used throughout the Gini codebase.
Synopsis
- atomicallyWithEnv :: (MonadIO m, MonadReader env m) => ReaderT env STM a -> m a
- periodically :: MonadIO m => NominalDiffTime -> (UTCTime -> m ()) -> m ()
- randomSample :: Int -> [a] -> StdGen -> ([a], StdGen)
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!