idiomatic elem

This commit is contained in:
Joey Hess 2011-01-30 12:01:56 -04:00
parent 96e561bc47
commit 1b0edc1ab2
5 changed files with 10 additions and 10 deletions

View file

@ -108,7 +108,7 @@ checkRemoveKey key numcopiesM = do
| length have >= need = return True
| otherwise = do
u <- getUUID r
let dup = elem u have
let dup = u `elem` have
haskey <- Remotes.inAnnex r key
case (dup, haskey) of
(False, Right True) -> findcopies need (u:have) rs bad
@ -139,7 +139,7 @@ showLocations key exclude = do
ppuuidsskipped <- prettyPrintUUIDs uuidsskipped
showLongNote $ message ppuuidswanted ppuuidsskipped
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 rs [] = "Try making some of these repositories available:\n" ++ rs
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
untrusted <- trustGet UnTrusted
let untrustedlocations = intersect untrusted locations
let safelocations = filter (\l -> not $ l `elem` untrusted) locations
let safelocations = filter (`notElem` untrusted) locations
let present = length safelocations
if present < needed
then do

View file

@ -75,5 +75,5 @@ instance Arbitrary Key where
prop_idempotent_key_read_show :: Key -> Bool
prop_idempotent_key_read_show k
-- backend names will never contain colons
| elem ':' (backendName k) = True
| ':' `elem` (backendName k) = True
| otherwise = k == (read $ show k)

View file

@ -88,7 +88,7 @@ reposByUUID repos uuids = filterM match repos
where
match r = do
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. -}
reposWithoutUUID :: [Git.Repo] -> [UUID] -> Annex [Git.Repo]
@ -96,7 +96,7 @@ reposWithoutUUID repos uuids = filterM unmatch repos
where
unmatch r = do
u <- getUUID r
return $ not $ elem u uuids
return $ u `notElem` uuids
{- Pretty-prints a list of UUIDs -}
prettyPrintUUIDs :: [UUID] -> Annex String

View file

@ -46,13 +46,13 @@ main' [] = failure
main' ("-c":p) = main' p
-- a command can be either a builtin or something to pass to git-shell
main' c@(cmd:dir:params)
| elem cmd builtins = builtin cmd dir params
| cmd `elem` builtins = builtin cmd dir params
| otherwise = external c
main' c@(cmd:_)
-- Handle the case of being the user's login shell. It will be passed
-- a single string containing all the real parameters.
| "git-annex-shell " `isPrefixOf` cmd = main' $ drop 1 $ shellUnEscape cmd
| elem cmd builtins = failure
| cmd `elem` builtins = failure
| otherwise = external c
builtins :: [String]

View file

@ -331,7 +331,7 @@ test_trust = "git-annex trust/untrust/semitrust" ~: intmpclonerepo $ do
l <- Trust.trustGet expected
r <- Remotes.byName repo
u <- UUID.getUUID r
return $ elem u l
return $ u `elem` l
assertBool msg present
repo = "origin"
@ -588,7 +588,7 @@ checklocationlog f expected = do
g <- Annex.gitRepo
liftIO $ LocationLog.keyLocations g k
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
-- into git, and any modifications staged for