| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Pantry.Internal.Companion
Description
Companion threads, such as for printing messages saying we're still busy. Ultimately this could be put into its own package. This is a non-standard API for use by Pantry and Stack, please /DO NOT DEPEND ON IT/.
Synopsis
- withCompanion :: forall m a. MonadUnliftIO m => Companion m -> (StopCompanion m -> m a) -> m a
- onCompanionDone :: MonadUnliftIO m => m () -> m () -> m ()
- type Companion m = Delay -> m ()
- type Delay = forall mio. MonadIO mio => Int -> mio ()
- type StopCompanion m = m ()
Documentation
withCompanion :: forall m a. MonadUnliftIO m => Companion m -> (StopCompanion m -> m a) -> m a Source #
Keep running the Companion action until either the inner action
completes or calls the StopCompanion action. This can be used to
give the user status information while running a long running
operations.
Arguments
| :: MonadUnliftIO m | |
| => m () | the delay |
| -> m () | action to perform |
| -> m () |
When a delay was interrupted because we're told to stop, perform this action.
type Companion m = Delay -> m () Source #
A companion thread which can perform arbitrary actions as well as delay
type Delay = forall mio. MonadIO mio => Int -> mio () Source #
Delay the given number of microseconds. If StopCompanion is
triggered before the timer completes, a CompanionDone exception
will be thrown (which is caught internally by withCompanion).