generalize to allow running in Assistant monad

This commit is contained in:
Joey Hess 2020-12-04 13:07:30 -04:00
parent 7a9b618d5d
commit 4efecaebd6
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 31 additions and 9 deletions

View file

@ -98,10 +98,14 @@ inOwnConsoleRegion s a
Regions.closeConsoleRegion r
{- The progress region is displayed inline with the current console region. -}
withProgressRegion :: (Regions.ConsoleRegion -> Annex a) -> Annex a
withProgressRegion a = do
parent <- consoleRegion <$> Annex.getState Annex.output
withProgressRegion
:: (MonadIO m, MonadMask m)
=> MessageState
-> (Regions.ConsoleRegion -> m a) -> m a
withProgressRegion st a =
Regions.withConsoleRegion (maybe Regions.Linear Regions.InLine parent) a
where
parent = consoleRegion st
instance Regions.LiftRegion Annex where
liftRegion = liftIO . atomically