diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-11-15 16:55:38 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-11-15 16:59:32 -0400 |
commit | 4888bd597e34dce996fd581bb417ce017099171b (patch) | |
tree | 8b97f6807b5528be6b00c8d21038057ca097ec29 /Annex/Ingest.hs | |
parent | 01c524779136a688abf312e721abce41d2dd109c (diff) |
enable LambdaCase and convert around 10% of places that could use it
Needs ghc 7.6.1, so minimum base version increased slightly. All builds
are well above this version of ghc, and debian oldstable is as well.
Code that could use lambdacase can be found by running:
git grep -B 1 'case ' | less
and searching in less for "<-"
This commit was sponsored by andrea rota.
Diffstat (limited to 'Annex/Ingest.hs')
-rw-r--r-- | Annex/Ingest.hs | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index 5fdcd042c..1bc081560 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -169,9 +169,8 @@ ingest' preferredbackend (Just (LockedDown cfg source)) mk = withTSDelta $ \delt ) go _ _ _ = failure "failed to generate a key" - golocked key mcache s = do - v <- tryNonAsync (moveAnnex key $ contentLocation source) - case v of + golocked key mcache s = + tryNonAsync (moveAnnex key $ contentLocation source) >>= \case Right True -> do populateAssociatedFiles key source success key mcache s @@ -184,8 +183,7 @@ ingest' preferredbackend (Just (LockedDown cfg source)) mk = withTSDelta $ \delt -- already has a hard link. cleanCruft source cleanOldKeys (keyFilename source) key - r <- linkToAnnex key (keyFilename source) (Just cache) - case r of + linkToAnnex key (keyFilename source) (Just cache) >>= \case LinkAnnexFailed -> failure "failed to link to annex" _ -> do finishIngestUnlocked' key source @@ -259,8 +257,7 @@ cleanOldKeys file newkey = do fs <- filter (/= ingestedf) . map (`fromTopFilePath` g) <$> Database.Keys.getAssociatedFiles key - fs' <- filterM (`sameInodeCache` caches) fs - case fs' of + filterM (`sameInodeCache` caches) fs >>= \case -- If linkToAnnex fails, the associated -- file with the content is still present, -- so no need for any recovery. @@ -342,14 +339,12 @@ cachedCurrentBranch = maybe cache (return . Just) =<< Annex.getState Annex.cachedcurrentbranch where cache :: Annex (Maybe Git.Branch) - cache = do - mb <- inRepo Git.Branch.currentUnsafe - case mb of - Nothing -> return Nothing - Just b -> do - Annex.changeState $ \s -> - s { Annex.cachedcurrentbranch = Just b } - return (Just b) + cache = inRepo Git.Branch.currentUnsafe >>= \case + Nothing -> return Nothing + Just b -> do + Annex.changeState $ \s -> + s { Annex.cachedcurrentbranch = Just b } + return (Just b) {- Adds a file to the work tree for the key, and stages it in the index. - The content of the key may be provided in a temp file, which will be @@ -389,10 +384,8 @@ addAnnexedFile file key mtmp = ifM (addUnlocked <&&> not <$> isDirect) Nothing -> return True ) where - linkunlocked mode = do - r <- linkFromAnnex key file mode - case r of - LinkAnnexFailed -> liftIO $ - writePointerFile file key mode - _ -> return () + linkunlocked mode = linkFromAnnex key file mode >>= \case + LinkAnnexFailed -> liftIO $ + writePointerFile file key mode + _ -> return () writepointer mode = liftIO $ writePointerFile file key mode |