From f4e2dde8a8ceaf689ec5391174b53cb1b213ea8b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 Oct 2010 20:47:14 -0400 Subject: fix perl refugee code --- Backend.hs | 6 +++--- Backend/File.hs | 10 +++++----- Commands.hs | 10 +++++----- Remotes.hs | 8 ++++---- UUID.hs | 2 +- Utility.hs | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Backend.hs b/Backend.hs index b8def21cd..c70b7b707 100644 --- a/Backend.hs +++ b/Backend.hs @@ -40,21 +40,21 @@ import qualified TypeInternals as Internals list :: Annex [Backend] list = do l <- Annex.backends -- list is cached here - if (0 < length l) + if (not $ null l) then return l else do all <- Annex.supportedBackends g <- Annex.gitRepo let l = parseBackendList all $ Git.configGet g "annex.backends" "" backendflag <- Annex.flagGet "backend" - let l' = if (0 < length backendflag) + let l' = if (not $ null backendflag) then (lookupBackendName all backendflag):l else l Annex.backendsChange $ l' return l' where parseBackendList all s = - if (length s == 0) + if (null s) then all else map (lookupBackendName all) $ words s diff --git a/Backend/File.hs b/Backend/File.hs index 797d48747..3396db3e5 100644 --- a/Backend/File.hs +++ b/Backend/File.hs @@ -62,7 +62,7 @@ checkKeyFile k = do copyKeyFile :: Key -> FilePath -> Annex (Bool) copyKeyFile key file = do remotes <- Remotes.withKey key - if (0 == length remotes) + if (null remotes) then do showNote "not available" showLocations key @@ -142,7 +142,7 @@ checkRemoveKey key = do "Could only verify the existence of " ++ (show have) ++ " out of " ++ (show need) ++ " necessary copies" - if (0 /= length bad) then showTriedRemotes bad else return () + if (not $ null bad) then showTriedRemotes bad else return () showLocations key hint return False @@ -156,9 +156,9 @@ showLocations key = do uuids <- liftIO $ keyLocations g key let uuidsf = filter (\v -> v /= u) uuids ppuuids <- prettyPrintUUIDs uuidsf - if (0 < length uuidsf) - then showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids - else showLongNote $ "No other repository is known to contain the file." + if (null uuidsf) + then showLongNote $ "No other repository is known to contain the file." + else showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids showTriedRemotes remotes = showLongNote $ "I was unable to access these remotes: " ++ diff --git a/Commands.hs b/Commands.hs index 3e7447c5b..cb923d5e5 100644 --- a/Commands.hs +++ b/Commands.hs @@ -117,9 +117,9 @@ findWanted Description params _ = do parseCmd :: [String] -> AnnexState -> IO ([Annex ()], [Annex ()]) parseCmd argv state = do (flags, params) <- getopt - case (length params) of - 0 -> error usage - _ -> case (lookupCmd (params !! 0)) of + if (null params) + then error usage + else case (lookupCmd (params !! 0)) of [] -> error usage [Command _ action want _] -> do f <- findWanted want (drop 1 params) @@ -258,7 +258,7 @@ fixCmd file = inBackend file $ \(key, backend) -> do {- Stores description for the repository. -} initCmd :: String -> Annex () initCmd description = do - if (0 == length description) + if (null description) then error $ "please specify a description of this repository\n" ++ usage @@ -275,7 +275,7 @@ initCmd description = do fromKeyCmd :: FilePath -> Annex () fromKeyCmd file = do keyname <- Annex.flagGet "key" - if (0 == length keyname) + if (null keyname) then error "please specify the key with --key" else return () backends <- Backend.list diff --git a/Remotes.hs b/Remotes.hs index 8418a4225..48ab9ef8c 100644 --- a/Remotes.hs +++ b/Remotes.hs @@ -49,11 +49,11 @@ withKey key = do let cheap = filter (not . Git.repoIsUrl) allremotes let expensive = filter Git.repoIsUrl allremotes doexpensive <- filterM cachedUUID expensive - if (0 < length doexpensive) + if (not $ null doexpensive) then showNote $ "getting UUIDs for " ++ (list doexpensive) ++ "..." else return () let todo = cheap ++ doexpensive - if (0 < length todo) + if (not $ null todo) then do e <- mapM tryGitConfigRead todo Annex.flagChange "remotesread" $ FlagBool True @@ -62,7 +62,7 @@ withKey key = do where cachedUUID r = do u <- getUUID r - return $ 0 == length u + return $ null u {- Cost Ordered list of remotes. -} remotesByCost :: Annex [Git.Repo] @@ -90,7 +90,7 @@ reposByCost l = do repoCost :: Git.Repo -> Annex Int repoCost r = do g <- Annex.gitRepo - if ((length $ config g r) > 0) + if (not $ null $ config g r) then return $ read $ config g r else if (Git.repoIsUrl r) then return 200 diff --git a/UUID.hs b/UUID.hs index 47d305c4f..a7783d614 100644 --- a/UUID.hs +++ b/UUID.hs @@ -103,7 +103,7 @@ prettyPrintUUIDs uuids = do return $ unwords $ map (\u -> "\t"++(prettify m u)++"\n") uuids where prettify m u = - if (0 < (length $ findlog m u)) + if (not $ null $ findlog m u) then u ++ " -- " ++ (findlog m u) else u findlog m u = M.findWithDefault "" u m diff --git a/Utility.hs b/Utility.hs index 8bffde057..8e620c64c 100644 --- a/Utility.hs +++ b/Utility.hs @@ -45,7 +45,7 @@ hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s {- Returns the parent directory of a path. Parent of / is "" -} parentDir :: String -> String parentDir dir = - if length dirs > 0 + if (not $ null dirs) then slash ++ (join s $ take ((length dirs) - 1) dirs) else "" where @@ -81,7 +81,7 @@ relPathCwdToDir dir = do -} relPathDirToDir :: FilePath -> FilePath -> FilePath relPathDirToDir from to = - if (0 < length path) + if (not $ null path) then addTrailingPathSeparator path else "" where -- cgit v1.2.3