diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-12-05 15:00:50 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-12-05 15:00:50 -0400 |
commit | 236c467da19f34edb08f124e37fd26eb62c43fcf (patch) | |
tree | f4e488f77fb954812e4d48f399fc2ecab072afea /Assistant | |
parent | f013f71cb5d3f7eee3afb3eb8f01a33206d717c4 (diff) |
more lambda-case conversion
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/MakeRemote.hs | 8 | ||||
-rw-r--r-- | Assistant/NamedThread.hs | 37 |
2 files changed, 20 insertions, 25 deletions
diff --git a/Assistant/MakeRemote.hs b/Assistant/MakeRemote.hs index b98e7f023..f49237157 100644 --- a/Assistant/MakeRemote.hs +++ b/Assistant/MakeRemote.hs @@ -79,17 +79,15 @@ initSpecialRemote name remotetype mcreds config = go 0 go :: Int -> Annex RemoteName go n = do let fullname = if n == 0 then name else name ++ show n - r <- Annex.SpecialRemote.findExisting fullname - case r of + Annex.SpecialRemote.findExisting fullname >>= \case Nothing -> setupSpecialRemote fullname remotetype config mcreds (Nothing, R.Init, Annex.SpecialRemote.newConfig fullname) Just _ -> go (n + 1) {- Enables an existing special remote. -} enableSpecialRemote :: SpecialRemoteMaker -enableSpecialRemote name remotetype mcreds config = do - r <- Annex.SpecialRemote.findExisting name - case r of +enableSpecialRemote name remotetype mcreds config = + Annex.SpecialRemote.findExisting name >>= \case Nothing -> error $ "Cannot find a special remote named " ++ name Just (u, c) -> setupSpecialRemote' False name remotetype config mcreds (Just u, R.Enable c, c) diff --git a/Assistant/NamedThread.hs b/Assistant/NamedThread.hs index 7acb70132..090a3a7cd 100644 --- a/Assistant/NamedThread.hs +++ b/Assistant/NamedThread.hs @@ -35,9 +35,8 @@ import qualified Data.Text as T - Named threads are run by a management thread, so if they crash - an alert is displayed, allowing the thread to be restarted. -} startNamedThread :: UrlRenderer -> NamedThread -> Assistant () -startNamedThread urlrenderer (NamedThread afterstartupsanitycheck name a) = do - m <- startedThreads <$> getDaemonStatus - case M.lookup name m of +startNamedThread urlrenderer (NamedThread afterstartupsanitycheck name a) = + M.lookup name . startedThreads <$> getDaemonStatus >>= \case Nothing -> start Just (aid, _) -> do r <- liftIO (E.try (poll aid) :: IO (Either E.SomeException (Maybe (Either E.SomeException ())))) @@ -65,24 +64,22 @@ startNamedThread urlrenderer (NamedThread afterstartupsanitycheck name a) = do a void $ forkIO $ manager d aid return aid - manager d aid = do - r <- E.try (wait aid) :: IO (Either E.SomeException ()) - case r of - Right _ -> noop - Left e -> do - let msg = unwords - [ fromThreadName $ threadName d - , "crashed:", show e - ] - hPutStrLn stderr msg + manager d aid = (E.try (wait aid) :: IO (Either E.SomeException ())) >>= \case + Right _ -> noop + Left e -> do + let msg = unwords + [ fromThreadName $ threadName d + , "crashed:", show e + ] + hPutStrLn stderr msg #ifdef WITH_WEBAPP - button <- runAssistant d $ mkAlertButton True - (T.pack "Restart Thread") - urlrenderer - (RestartThreadR name) - runAssistant d $ void $ addAlert $ - (warningAlert (fromThreadName name) msg) - { alertButtons = [button] } + button <- runAssistant d $ mkAlertButton True + (T.pack "Restart Thread") + urlrenderer + (RestartThreadR name) + runAssistant d $ void $ addAlert $ + (warningAlert (fromThreadName name) msg) + { alertButtons = [button] } #endif namedThreadId :: NamedThread -> Assistant (Maybe ThreadId) |