Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Monad.TimeMachine.Engine
- class Monad m => MonadTime m where
- getTimeZone :: MonadTime m => UTCTime -> m TimeZone
- getCurrentTimeZone :: MonadTime m => m TimeZone
- utcToLocalZonedTime :: MonadTime m => UTCTime -> m ZonedTime
- getZonedTime :: MonadTime m => m ZonedTime
- loadLocalTZ :: MonadTime m => m TZ
- departFor :: (MonadIO m, MonadTime m) => Destination -> TimeZoneName -> Acceleration -> TimeMachineT m a -> m a
- travelTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a
- backTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a
- jumpTo :: (MonadIO m, MonadTime m) => TimeZoneName -> TimeMachineT m a -> m a
- accelerate :: (MonadIO m, MonadTime m) => Acceleration -> TimeMachineT m a -> m a
- halt :: (MonadIO m, MonadTime m) => TimeMachineT m a -> m a
- newtype TimeScale = TimeScale {}
- data Destination
- data TimeInterval
- type TimeZoneName = String
- data Acceleration
- data TimeMachineT m a
MonadTime Class
class Monad m => MonadTime m where Source #
A class of monads in which you can obrain the mocked current time and relevant information.
Minimal complete definition
getTimeZone :: MonadTime m => UTCTime -> m TimeZone Source #
Returns the mocked time zone at the given point of time.
getCurrentTimeZone :: MonadTime m => m TimeZone Source #
Returns the mocked time zone at the mocked current time.
utcToLocalZonedTime :: MonadTime m => UTCTime -> m ZonedTime Source #
Returns the mocked local time at the given point of time.
getZonedTime :: MonadTime m => m ZonedTime Source #
Returns the mocked local time at the mocked current time.
loadLocalTZ :: MonadTime m => m TZ Source #
An alias of getCurrentTZ
.
Functions
departFor :: (MonadIO m, MonadTime m) => Destination -> TimeZoneName -> Acceleration -> TimeMachineT m a -> m a Source #
Switches the MonadTime
contexts.
You can specify all of the point of time, the time zone and
the setting of speed for mocking at once.
travelTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a Source #
Switches the mocked current time in the context.
backTo :: (MonadIO m, MonadTime m) => Destination -> TimeMachineT m a -> m a Source #
An alias of travelTo
.
jumpTo :: (MonadIO m, MonadTime m) => TimeZoneName -> TimeMachineT m a -> m a Source #
Switches the mocked current time zone in the context.
accelerate :: (MonadIO m, MonadTime m) => Acceleration -> TimeMachineT m a -> m a Source #
Changes the mocked speed of time in the context.
halt :: (MonadIO m, MonadTime m) => TimeMachineT m a -> m a Source #
Stops the time to advence in the context.
Configurations
A data type to represents the speed of time.
It corresponds how many seconds are in the real second,
i.e. TimeScale 1
is equivalent to the real speed of time.
Constructors
TimeScale | |
Fields |
data Destination Source #
A data type to represent a point of time for mocking.
Constructors
None | Nothing to mock. |
Absolute UTCTime | An absolute point in UTC. |
Zoned LocalTime | A local time in the mocked current time zone. |
Relative TimeInterval | An interval from the mocked current time. |
Instances
data TimeInterval Source #
A data type to represent intervals for constructing a Destination
.
Instances
type TimeZoneName = String Source #
Names of time zones, e.g. "Asia/Tokyo"
or "Europe/Paris"
.
data Acceleration Source #
A data type to represent how to change the mocked speed of time.
Constructors
Keep | Nothing to change. |
Velocity TimeScale | Sets the speed to the given scale. |
Factor TimeScale | Sets the speed acccording to the current speed. |
Instances
Monad Transformer
data TimeMachineT m a Source #
A monad transformer to stack the MonadTime
contexts.
Instances
MonadTrans TimeMachineT Source # | |
Monad m => Monad (TimeMachineT m) Source # | |
Functor m => Functor (TimeMachineT m) Source # | |
Applicative m => Applicative (TimeMachineT m) Source # | |
MonadIO m => MonadIO (TimeMachineT m) Source # | |
MonadIO m => MonadTime (TimeMachineT m) Source # | |