mock-time-0.1.0: Mock time in tests
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Trans.SimulatedTime

Description

An implementation of MonadTime with a monad transformer.

Synopsis

Documentation

newtype SimulatedTimeT m a Source #

A newtype wrapper over ReaderT TimeEnv

Constructors

SimulatedTimeT 

Instances

Instances details
MonadTrans SimulatedTimeT Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

lift :: Monad m => m a -> SimulatedTimeT m a #

MonadWriter w m => MonadWriter w (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

writer :: (a, w) -> SimulatedTimeT m a #

tell :: w -> SimulatedTimeT m () #

listen :: SimulatedTimeT m a -> SimulatedTimeT m (a, w) #

pass :: SimulatedTimeT m (a, w -> w) -> SimulatedTimeT m a #

MonadState s m => MonadState s (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

get :: SimulatedTimeT m s #

put :: s -> SimulatedTimeT m () #

state :: (s -> (a, s)) -> SimulatedTimeT m a #

MonadReader r m => MonadReader r (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

ask :: SimulatedTimeT m r #

local :: (r -> r) -> SimulatedTimeT m a -> SimulatedTimeT m a #

reader :: (r -> a) -> SimulatedTimeT m a #

MonadError e m => MonadError e (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

throwError :: e -> SimulatedTimeT m a #

catchError :: SimulatedTimeT m a -> (e -> SimulatedTimeT m a) -> SimulatedTimeT m a #

Monad m => Monad (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

(>>=) :: SimulatedTimeT m a -> (a -> SimulatedTimeT m b) -> SimulatedTimeT m b #

(>>) :: SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m b #

return :: a -> SimulatedTimeT m a #

Functor m => Functor (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

fmap :: (a -> b) -> SimulatedTimeT m a -> SimulatedTimeT m b #

(<$) :: a -> SimulatedTimeT m b -> SimulatedTimeT m a #

MonadFix m => MonadFix (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mfix :: (a -> SimulatedTimeT m a) -> SimulatedTimeT m a #

MonadFail m => MonadFail (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

fail :: String -> SimulatedTimeT m a #

Applicative m => Applicative (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

pure :: a -> SimulatedTimeT m a #

(<*>) :: SimulatedTimeT m (a -> b) -> SimulatedTimeT m a -> SimulatedTimeT m b #

liftA2 :: (a -> b -> c) -> SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m c #

(*>) :: SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m b #

(<*) :: SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m a #

MonadZip m => MonadZip (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mzip :: SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m (a, b) #

mzipWith :: (a -> b -> c) -> SimulatedTimeT m a -> SimulatedTimeT m b -> SimulatedTimeT m c #

munzip :: SimulatedTimeT m (a, b) -> (SimulatedTimeT m a, SimulatedTimeT m b) #

MonadIO m => MonadIO (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

liftIO :: IO a -> SimulatedTimeT m a #

Alternative m => Alternative (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

MonadPlus m => MonadPlus (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

MonadThrow m => MonadThrow (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

throwM :: Exception e => e -> SimulatedTimeT m a #

MonadCatch m => MonadCatch (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

catch :: Exception e => SimulatedTimeT m a -> (e -> SimulatedTimeT m a) -> SimulatedTimeT m a #

MonadMask m => MonadMask (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mask :: ((forall a. SimulatedTimeT m a -> SimulatedTimeT m a) -> SimulatedTimeT m b) -> SimulatedTimeT m b #

uninterruptibleMask :: ((forall a. SimulatedTimeT m a -> SimulatedTimeT m a) -> SimulatedTimeT m b) -> SimulatedTimeT m b #

generalBracket :: SimulatedTimeT m a -> (a -> ExitCase b -> SimulatedTimeT m c) -> (a -> SimulatedTimeT m b) -> SimulatedTimeT m (b, c) #

MonadCont m => MonadCont (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

callCC :: ((a -> SimulatedTimeT m b) -> SimulatedTimeT m a) -> SimulatedTimeT m a #

PrimMonad m => PrimMonad (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Associated Types

type PrimState (SimulatedTimeT m) #

MonadResource m => MonadResource (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

MonadUnliftIO m => MonadUnliftIO (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

withRunInIO :: ((forall a. SimulatedTimeT m a -> IO a) -> IO b) -> SimulatedTimeT m b #

MonadIO m => MonadTime (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

type PrimState (SimulatedTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

runSimulatedTimeT :: SimulatedTimeT m a -> TimeEnv -> m a Source #

Run the reader

newtype RealTimeT m a Source #

An implementation for MonadTime that uses real time directly, not allowing for control. Use it from code where you need to choose implementation for MockTime, but don't need to control the time.

Example: use this one in the executable, while SimulatedTimeT is used in tests that need to control time.

Constructors

RealTimeT 

Fields

Instances

Instances details
MonadWriter w m => MonadWriter w (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

writer :: (a, w) -> RealTimeT m a #

tell :: w -> RealTimeT m () #

listen :: RealTimeT m a -> RealTimeT m (a, w) #

pass :: RealTimeT m (a, w -> w) -> RealTimeT m a #

MonadState s m => MonadState s (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

get :: RealTimeT m s #

put :: s -> RealTimeT m () #

state :: (s -> (a, s)) -> RealTimeT m a #

MonadReader s m => MonadReader s (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

ask :: RealTimeT m s #

local :: (s -> s) -> RealTimeT m a -> RealTimeT m a #

reader :: (s -> a) -> RealTimeT m a #

MonadError e m => MonadError e (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

throwError :: e -> RealTimeT m a #

catchError :: RealTimeT m a -> (e -> RealTimeT m a) -> RealTimeT m a #

Monad m => Monad (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

(>>=) :: RealTimeT m a -> (a -> RealTimeT m b) -> RealTimeT m b #

(>>) :: RealTimeT m a -> RealTimeT m b -> RealTimeT m b #

return :: a -> RealTimeT m a #

Functor m => Functor (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

fmap :: (a -> b) -> RealTimeT m a -> RealTimeT m b #

(<$) :: a -> RealTimeT m b -> RealTimeT m a #

MonadFix m => MonadFix (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mfix :: (a -> RealTimeT m a) -> RealTimeT m a #

MonadFail m => MonadFail (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

fail :: String -> RealTimeT m a #

Applicative m => Applicative (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

pure :: a -> RealTimeT m a #

(<*>) :: RealTimeT m (a -> b) -> RealTimeT m a -> RealTimeT m b #

liftA2 :: (a -> b -> c) -> RealTimeT m a -> RealTimeT m b -> RealTimeT m c #

(*>) :: RealTimeT m a -> RealTimeT m b -> RealTimeT m b #

(<*) :: RealTimeT m a -> RealTimeT m b -> RealTimeT m a #

MonadZip m => MonadZip (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mzip :: RealTimeT m a -> RealTimeT m b -> RealTimeT m (a, b) #

mzipWith :: (a -> b -> c) -> RealTimeT m a -> RealTimeT m b -> RealTimeT m c #

munzip :: RealTimeT m (a, b) -> (RealTimeT m a, RealTimeT m b) #

MonadIO m => MonadIO (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

liftIO :: IO a -> RealTimeT m a #

Alternative m => Alternative (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

empty :: RealTimeT m a #

(<|>) :: RealTimeT m a -> RealTimeT m a -> RealTimeT m a #

some :: RealTimeT m a -> RealTimeT m [a] #

many :: RealTimeT m a -> RealTimeT m [a] #

MonadPlus m => MonadPlus (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mzero :: RealTimeT m a #

mplus :: RealTimeT m a -> RealTimeT m a -> RealTimeT m a #

MonadThrow m => MonadThrow (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

throwM :: Exception e => e -> RealTimeT m a #

MonadCatch m => MonadCatch (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

catch :: Exception e => RealTimeT m a -> (e -> RealTimeT m a) -> RealTimeT m a #

MonadMask m => MonadMask (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

mask :: ((forall a. RealTimeT m a -> RealTimeT m a) -> RealTimeT m b) -> RealTimeT m b #

uninterruptibleMask :: ((forall a. RealTimeT m a -> RealTimeT m a) -> RealTimeT m b) -> RealTimeT m b #

generalBracket :: RealTimeT m a -> (a -> ExitCase b -> RealTimeT m c) -> (a -> RealTimeT m b) -> RealTimeT m (b, c) #

MonadCont m => MonadCont (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

callCC :: ((a -> RealTimeT m b) -> RealTimeT m a) -> RealTimeT m a #

PrimMonad m => PrimMonad (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Associated Types

type PrimState (RealTimeT m) #

Methods

primitive :: (State# (PrimState (RealTimeT m)) -> (# State# (PrimState (RealTimeT m)), a #)) -> RealTimeT m a #

MonadResource m => MonadResource (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

liftResourceT :: ResourceT IO a -> RealTimeT m a #

MonadUnliftIO m => MonadUnliftIO (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

Methods

withRunInIO :: ((forall a. RealTimeT m a -> IO a) -> IO b) -> RealTimeT m b #

MonadIO m => MonadTime (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

type PrimState (RealTimeT m) Source # 
Instance details

Defined in Control.Monad.Trans.SimulatedTime

getTimeEnv :: Monad m => SimulatedTimeT m TimeEnv Source #

Use TimeEnv to control the simulated time, for instance call advance on it to advance in simulated time.