idiomatic elem
This commit is contained in:
parent
96e561bc47
commit
1b0edc1ab2
5 changed files with 10 additions and 10 deletions
|
@ -108,7 +108,7 @@ checkRemoveKey key numcopiesM = do
|
||||||
| length have >= need = return True
|
| length have >= need = return True
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
u <- getUUID r
|
u <- getUUID r
|
||||||
let dup = elem u have
|
let dup = u `elem` have
|
||||||
haskey <- Remotes.inAnnex r key
|
haskey <- Remotes.inAnnex r key
|
||||||
case (dup, haskey) of
|
case (dup, haskey) of
|
||||||
(False, Right True) -> findcopies need (u:have) rs bad
|
(False, Right True) -> findcopies need (u:have) rs bad
|
||||||
|
@ -139,7 +139,7 @@ showLocations key exclude = do
|
||||||
ppuuidsskipped <- prettyPrintUUIDs uuidsskipped
|
ppuuidsskipped <- prettyPrintUUIDs uuidsskipped
|
||||||
showLongNote $ message ppuuidswanted ppuuidsskipped
|
showLongNote $ message ppuuidswanted ppuuidsskipped
|
||||||
where
|
where
|
||||||
filteruuids list x = filter (\l -> not $ elem l x) list
|
filteruuids list x = filter (`notElem` x) list
|
||||||
message [] [] = "No other repository is known to contain the file."
|
message [] [] = "No other repository is known to contain the file."
|
||||||
message rs [] = "Try making some of these repositories available:\n" ++ rs
|
message rs [] = "Try making some of these repositories available:\n" ++ rs
|
||||||
message [] us = "Also these untrusted repositories may contain the file:\n" ++ us
|
message [] us = "Also these untrusted repositories may contain the file:\n" ++ us
|
||||||
|
@ -179,7 +179,7 @@ checkKeyNumCopies key file numcopies = do
|
||||||
locations <- liftIO $ keyLocations g key
|
locations <- liftIO $ keyLocations g key
|
||||||
untrusted <- trustGet UnTrusted
|
untrusted <- trustGet UnTrusted
|
||||||
let untrustedlocations = intersect untrusted locations
|
let untrustedlocations = intersect untrusted locations
|
||||||
let safelocations = filter (\l -> not $ l `elem` untrusted) locations
|
let safelocations = filter (`notElem` untrusted) locations
|
||||||
let present = length safelocations
|
let present = length safelocations
|
||||||
if present < needed
|
if present < needed
|
||||||
then do
|
then do
|
||||||
|
|
|
@ -75,5 +75,5 @@ instance Arbitrary Key where
|
||||||
prop_idempotent_key_read_show :: Key -> Bool
|
prop_idempotent_key_read_show :: Key -> Bool
|
||||||
prop_idempotent_key_read_show k
|
prop_idempotent_key_read_show k
|
||||||
-- backend names will never contain colons
|
-- backend names will never contain colons
|
||||||
| elem ':' (backendName k) = True
|
| ':' `elem` (backendName k) = True
|
||||||
| otherwise = k == (read $ show k)
|
| otherwise = k == (read $ show k)
|
||||||
|
|
4
UUID.hs
4
UUID.hs
|
@ -88,7 +88,7 @@ reposByUUID repos uuids = filterM match repos
|
||||||
where
|
where
|
||||||
match r = do
|
match r = do
|
||||||
u <- getUUID r
|
u <- getUUID r
|
||||||
return $ elem u uuids
|
return $ u `elem` uuids
|
||||||
|
|
||||||
{- Filters a list of repos to ones that do not have the listed UUIDs. -}
|
{- Filters a list of repos to ones that do not have the listed UUIDs. -}
|
||||||
reposWithoutUUID :: [Git.Repo] -> [UUID] -> Annex [Git.Repo]
|
reposWithoutUUID :: [Git.Repo] -> [UUID] -> Annex [Git.Repo]
|
||||||
|
@ -96,7 +96,7 @@ reposWithoutUUID repos uuids = filterM unmatch repos
|
||||||
where
|
where
|
||||||
unmatch r = do
|
unmatch r = do
|
||||||
u <- getUUID r
|
u <- getUUID r
|
||||||
return $ not $ elem u uuids
|
return $ u `notElem` uuids
|
||||||
|
|
||||||
{- Pretty-prints a list of UUIDs -}
|
{- Pretty-prints a list of UUIDs -}
|
||||||
prettyPrintUUIDs :: [UUID] -> Annex String
|
prettyPrintUUIDs :: [UUID] -> Annex String
|
||||||
|
|
|
@ -46,13 +46,13 @@ main' [] = failure
|
||||||
main' ("-c":p) = main' p
|
main' ("-c":p) = main' p
|
||||||
-- a command can be either a builtin or something to pass to git-shell
|
-- a command can be either a builtin or something to pass to git-shell
|
||||||
main' c@(cmd:dir:params)
|
main' c@(cmd:dir:params)
|
||||||
| elem cmd builtins = builtin cmd dir params
|
| cmd `elem` builtins = builtin cmd dir params
|
||||||
| otherwise = external c
|
| otherwise = external c
|
||||||
main' c@(cmd:_)
|
main' c@(cmd:_)
|
||||||
-- Handle the case of being the user's login shell. It will be passed
|
-- Handle the case of being the user's login shell. It will be passed
|
||||||
-- a single string containing all the real parameters.
|
-- a single string containing all the real parameters.
|
||||||
| "git-annex-shell " `isPrefixOf` cmd = main' $ drop 1 $ shellUnEscape cmd
|
| "git-annex-shell " `isPrefixOf` cmd = main' $ drop 1 $ shellUnEscape cmd
|
||||||
| elem cmd builtins = failure
|
| cmd `elem` builtins = failure
|
||||||
| otherwise = external c
|
| otherwise = external c
|
||||||
|
|
||||||
builtins :: [String]
|
builtins :: [String]
|
||||||
|
|
4
test.hs
4
test.hs
|
@ -331,7 +331,7 @@ test_trust = "git-annex trust/untrust/semitrust" ~: intmpclonerepo $ do
|
||||||
l <- Trust.trustGet expected
|
l <- Trust.trustGet expected
|
||||||
r <- Remotes.byName repo
|
r <- Remotes.byName repo
|
||||||
u <- UUID.getUUID r
|
u <- UUID.getUUID r
|
||||||
return $ elem u l
|
return $ u `elem` l
|
||||||
assertBool msg present
|
assertBool msg present
|
||||||
repo = "origin"
|
repo = "origin"
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ checklocationlog f expected = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
liftIO $ LocationLog.keyLocations g k
|
liftIO $ LocationLog.keyLocations g k
|
||||||
assertEqual ("bad content in location log for " ++ f ++ " key " ++ (show k) ++ " uuid " ++ thisuuid)
|
assertEqual ("bad content in location log for " ++ f ++ " key " ++ (show k) ++ " uuid " ++ thisuuid)
|
||||||
expected (elem thisuuid uuids)
|
expected (thisuuid `elem` uuids)
|
||||||
|
|
||||||
-- Location log files should always be checked
|
-- Location log files should always be checked
|
||||||
-- into git, and any modifications staged for
|
-- into git, and any modifications staged for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue