-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Timers, timeouts, alarms, monadic wrappers -- -- This library provides several timer and timeout related tools: -- --
-- >>> timeout (3 :: Second) $ delay (1 :: Second) >> return "hello" -- Just "hello" ---- --
-- >>> timeout (3 :: Second) $ delay (5 :: Second) >> return "hello" -- Nothing ---- --
-- >>> timeout (1 :: Second) $ error "hello" -- *** Exception: hello --timeout :: (TimeUnit t, MonadIO m, MonadCatch m) => t -> m a -> m (Maybe a) -- | Suspend the current thread for the given amount of time. -- -- Example: -- --
-- delay (5 :: Second) --delay :: (TimeUnit t, MonadIO m) => t -> m () instance GHC.Show.Show Control.Timeout.Timeout' instance GHC.Exception.Exception Control.Timeout.Timeout' instance Control.Monad.Timeout.Class.MonadTimeout GHC.Types.IO GHC.Types.IO -- | Manage a timer running in a dedicated thread. You specify an amount of -- time an and action. The timer waits for that amount of time, and then -- runs the action. You can stop and restart it at any time. module Control.Timer data TimerSettings n tsDelay :: TimerSettings n -> TimeInterval tsRun :: TimerSettings n -> n () -> IO () tsAction :: TimerSettings n -> n () data Timer n newTimer :: (MonadIO m, MonadIO n, MonadCatch n) => TimerSettings n -> m (Timer n) releaseTimer :: MonadIO m => Timer n -> m () withTimer :: (MonadIO m, MonadMask m, MonadIO n, MonadCatch n) => TimerSettings n -> (Timer n -> m a) -> m a startTimer :: MonadIO m => Timer n -> m () startTimer' :: (TimeUnit t, MonadIO m) => Timer n -> t -> m () startTimerWith :: (TimeUnit t, MonadIO m) => Timer n -> Maybe t -> Maybe (n ()) -> m () stopTimer :: MonadIO m => Timer n -> m () restartTimer :: MonadIO m => Timer n -> m () restartTimer' :: (TimeUnit t, MonadIO m) => Timer n -> t -> m () restartTimerWith :: (TimeUnit t, MonadIO m) => Timer n -> Maybe t -> Maybe (n ()) -> m () instance GHC.Show.Show Control.Timer.StopTimer instance GHC.Exception.Exception Control.Timer.StopTimer instance Control.Monad.IO.Class.MonadIO n => Data.Default.Class.Default (Control.Timer.TimerSettings n) -- | Monad transformer for managing a timer. module Control.Monad.Trans.Timer data TimerT n m a runTimerT :: (MonadIO m, MonadMask m, MonadIO n, MonadCatch n) => TimerT n m a -> TimerSettings n -> m a startTimer :: MonadIO m => TimerT n m () startTimer' :: (MonadIO m, TimeUnit t) => t -> TimerT n m () startTimerWith :: (TimeUnit t, MonadIO m) => Maybe t -> Maybe (n ()) -> TimerT n m () stopTimer :: MonadIO m => TimerT n m () restartTimer :: MonadIO m => TimerT n m () restartTimer' :: (TimeUnit t, MonadIO m) => t -> TimerT n m () restartTimerWith :: (TimeUnit t, MonadIO m) => Maybe t -> Maybe (n ()) -> TimerT n m () instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Trans.Timer.TimerT n m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Trans.Timer.TimerT n m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Trans.Timer.TimerT n m) instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Timer.TimerT n) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Timer.TimerT n m) instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Timer.TimerT n m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Timer.TimerT n m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Timer.TimerT n m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Timer.TimerT n m) -- | Manage an alarm clock running in a dedicated thread. -- -- You specify an amount of time. The alarm clock waits for that amount -- of time, and then throws an exception back to you, to notify you the -- time has passed. You can stop and restart it at any time. -- -- This is simply a convenient wrapper over Control.Timer, offered -- here becuase a common use of timers is to run actions with a time -- limit (timeout), and the API here makes it more straight-forward to -- do. module Control.Alarm data Alarm data AlarmWake newAlarm :: (TimeUnit t, MonadIO m) => t -> m Alarm releaseAlarm :: MonadIO m => Alarm -> m () withAlarm :: (TimeUnit t, MonadIO m, MonadMask m) => t -> (Alarm -> m a) -> m a startAlarm :: MonadIO m => Alarm -> m () startAlarm' :: (TimeUnit t, MonadIO m) => Alarm -> t -> m () stopAlarm :: MonadIO m => Alarm -> m () restartAlarm :: MonadIO m => Alarm -> m () restartAlarm' :: (TimeUnit t, MonadIO m) => Alarm -> t -> m () alarm :: (MonadIO m, MonadCatch m) => Alarm -> m a -> m (Maybe a) alarm' :: (TimeUnit t, MonadIO m, MonadCatch m) => Alarm -> t -> m a -> m (Maybe a) instance GHC.Show.Show Control.Alarm.AlarmWake instance GHC.Exception.Exception Control.Alarm.AlarmWake -- | Monad transformer for managing an alarm clock. module Control.Monad.Trans.Alarm data AlarmT m a runAlarmT :: (TimeUnit t, MonadIO m, MonadMask m) => AlarmT m a -> t -> m a startAlarm :: MonadIO m => AlarmT m () startAlarm' :: (TimeUnit t, MonadIO m) => t -> AlarmT m () stopAlarm :: MonadIO m => AlarmT m () restartAlarm :: MonadIO m => AlarmT m () restartAlarm' :: (TimeUnit t, MonadIO m) => t -> AlarmT m () alarm :: (MonadIO m, MonadCatch m) => m a -> AlarmT m (Maybe a) alarm' :: (TimeUnit t, MonadIO m, MonadCatch m) => t -> m a -> AlarmT m (Maybe a) instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Trans.Alarm.AlarmT m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Trans.Alarm.AlarmT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Trans.Alarm.AlarmT m) instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Alarm.AlarmT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Alarm.AlarmT m) instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Alarm.AlarmT m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Alarm.AlarmT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Alarm.AlarmT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Alarm.AlarmT m) -- | Monad transformer for running actions with a time limit. Provides a -- scalable MonadTimeout instance (at least for the case of a -- constant number of long-running threads). If you need to use timeouts -- often in a computation, this is probably better than -- Control.Timeout. module Control.Monad.Trans.Timeout -- | Monad transformer which gives your monad stack an ability to run -- actions with a timeout, and abort them if they don't finish within the -- time limit. -- -- By default, e.g. if you lift or liftIO an action, it -- runs in the regular way without a timeout. Use one of the timeout -- functions, such as withTimeoutThrow, to use the timeout. data TimeoutT m a runTimeoutT :: (TimeUnit t, MonadIO m, MonadMask m) => TimeoutT m a -> t -> m a withTimeoutThrow :: (MonadIO m, MonadCatch m) => m a -> TimeoutT m a withTimeoutThrow' :: (TimeUnit t, MonadIO m, MonadCatch m) => t -> m a -> TimeoutT m a withTimeoutCatch :: (MonadIO m, MonadCatch m) => m a -> TimeoutT m (Maybe a) withTimeoutCatch' :: (TimeUnit t, MonadCatch m, MonadIO m) => t -> m a -> TimeoutT m (Maybe a) instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Trans.Timeout.TimeoutT m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Trans.Timeout.TimeoutT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Trans.Timeout.TimeoutT m) instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Timeout.TimeoutT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Timeout.TimeoutT m) instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Timeout.TimeoutT m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Timeout.TimeoutT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Timeout.TimeoutT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Timeout.TimeoutT m) instance (Control.Monad.IO.Class.MonadIO m, Control.Monad.Catch.MonadCatch m) => Control.Monad.Timeout.Class.MonadTimeout (Control.Monad.Trans.Timeout.TimeoutT m) m