diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-22 17:51:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-22 17:51:55 -0400 |
commit | eeae91024285c85a7e77b1b44e501a63bced7154 (patch) | |
tree | ece6c1d1e670e04001dd570a375ed9954078da0a /Utility.hs | |
parent | 57adb0347bf4eb71ab846a2947680a20263449a2 (diff) |
finished hlinting
Diffstat (limited to 'Utility.hs')
-rw-r--r-- | Utility.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Utility.hs b/Utility.hs index 33db4bb08..2bea6e875 100644 --- a/Utility.hs +++ b/Utility.hs @@ -35,12 +35,12 @@ 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 (not $ null dirs) - then slash ++ (join s $ take ((length dirs) - 1) dirs) + if not $ null dirs + then slash ++ join s (take (length dirs - 1) dirs) else "" where - dirs = filter (\x -> not $ null x) $ split s dir - slash = if (not $ isAbsolute dir) then "" else s + dirs = filter (not . null) $ split s dir + slash = if isAbsolute dir then s else "" s = [pathSeparator] {- Constructs a relative path from the CWD to a directory. @@ -58,7 +58,7 @@ relPathCwdToDir dir = do where -- absolute, normalized form of the directory absnorm cwd = - case (absNormPath cwd dir) of + case absNormPath cwd dir of Just d -> d Nothing -> error $ "unable to normalize " ++ dir @@ -70,7 +70,7 @@ relPathCwdToDir dir = do -} relPathDirToDir :: FilePath -> FilePath -> FilePath relPathDirToDir from to = - if (not $ null path) + if not $ null path then addTrailingPathSeparator path else "" where @@ -80,8 +80,8 @@ relPathDirToDir from to = common = map fst $ filter same $ zip pfrom pto same (c,d) = c == d uncommon = drop numcommon pto - dotdots = take ((length pfrom) - numcommon) $ repeat ".." - numcommon = length $ common + dotdots = replicate (length pfrom - numcommon) ".." + numcommon = length common path = join s $ dotdots ++ uncommon {- Run a system command, and returns True or False @@ -124,4 +124,4 @@ shellEscape f = "'" ++ escaped ++ "'" unsetFileMode :: FilePath -> FileMode -> IO () unsetFileMode f m = do s <- getFileStatus f - setFileMode f $ (fileMode s) `intersectFileModes` (complement m) + setFileMode f $ fileMode s `intersectFileModes` complement m |