REF use bracket
This commit is contained in:
parent
b52b22c48d
commit
c94d83f41e
|
@ -46,12 +46,8 @@ class SafeClient c where
|
|||
disconnectDBusClient = liftIO . disconnect . toClient
|
||||
|
||||
withDBusClient :: MonadUnliftIO m => (c -> m a) -> m (Maybe a)
|
||||
withDBusClient f = do
|
||||
client <- getDBusClient
|
||||
forM client $ \c -> do
|
||||
r <- f c
|
||||
liftIO $ disconnect (toClient c)
|
||||
return r
|
||||
withDBusClient f =
|
||||
bracket getDBusClient (mapM (liftIO . disconnect . toClient)) $ mapM f
|
||||
|
||||
withDBusClient_ :: MonadUnliftIO m => (c -> m ()) -> m ()
|
||||
withDBusClient_ = void . withDBusClient
|
||||
|
|
Loading…
Reference in New Issue