-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Cache current time and formatted time text
--
-- Suppose you have an IO action which runs very frequently, and one of
-- the things it does is getting the current UTCTime, possibly
-- also formatting it into a String or Text. The action cares about the
-- current minute, and doesn't care about seconds or milliseconds at all.
-- Instead of reading and formatting the time many times, using this
-- library you can keep a cache which updates every minute (or other
-- interval) and allows your application to scale without time reading
-- and formatting ever becoming a bottleneck.
--
-- There are 2 modules provided. I suggest you start with the monadic
-- one, especially for simple usage, and switch to the other one if you
-- need some custom solution.
--
-- The Data.Time.Cache module allows you to create a time caching
-- action which returns time and a formatted time string. But instead of
-- directly reading the time and running a formatter, it takes the values
-- from a cache it periodically updates.
--
-- The Control.Monad.Trans.Time module provides a convenient
-- monadic wrapper for the time cache.
--
-- If you need the time cache in multiple threads, you can create the
-- time getter once and then pass to all the threads to share.
@package time-cache
@version 0.1
module Data.Time.Cache
type TimeGetter = IO (UTCTime, Text)
mkTimeGetter :: TimeUnit t => t -> TimeLocale -> String -> IO TimeGetter
module Control.Monad.Trans.Time
class Monad m => MonadTime m
askTime :: MonadTime m => m UTCTime
class MonadTime m => MonadTimeFormat m where askTimeAndFormat = (,) <$> askTime <*> askFormattedTime
askFormattedTime :: MonadTimeFormat m => m Text
askTimeAndFormat :: MonadTimeFormat m => m (UTCTime, Text)
data TimeT m a
runTimeT :: TimeT m a -> TimeLocale -> String -> m a
data TimeCacheT m a
runTimeCacheT :: (TimeUnit t, MonadIO m) => TimeCacheT m a -> t -> TimeLocale -> String -> m a
runTimeCacheTWithGetter :: TimeCacheT m a -> TimeGetter -> m a
askTimeGetter :: Monad m => TimeCacheT m TimeGetter
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Time.TimeCacheT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Time.TimeCacheT m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Time.TimeCacheT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Time.TimeCacheT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Time.TimeCacheT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Time.TimeCacheT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Time.TimeT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Time.TimeT m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Time.TimeT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Time.TimeT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Time.TimeT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Time.TimeT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Trans.Time.MonadTime (Control.Monad.Trans.Time.TimeT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Trans.Time.MonadTimeFormat (Control.Monad.Trans.Time.TimeT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Trans.Time.MonadTime (Control.Monad.Trans.Time.TimeCacheT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Trans.Time.MonadTimeFormat (Control.Monad.Trans.Time.TimeCacheT m)