From 760cde28b67c14e0ad68e8649c0abe0544c44947 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 May 2011 14:49:28 -0400 Subject: more pointless monadic golfing --- GitRepo.hs | 3 +-- Locations.hs | 2 +- Remote/S3real.hs | 2 +- Utility.hs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/GitRepo.hs b/GitRepo.hs index 3c5a1e129..87cceece4 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -577,8 +577,7 @@ encodeGitFile s = foldl (++) "\"" (map echar s) ++ "\"" e_num c = showoctal $ ord c -- unicode character is decomposed to -- Word8s and each is shown in octal - e_utf c = concat $ map showoctal $ - (encode [c] :: [Word8]) + e_utf c = showoctal =<< (encode [c] :: [Word8]) {- for quickcheck -} prop_idempotent_deencode :: String -> Bool diff --git a/Locations.hs b/Locations.hs index 1c4f8296e..38a320a2b 100644 --- a/Locations.hs +++ b/Locations.hs @@ -175,7 +175,7 @@ prop_idempotent_fileKey s = Just k == fileKey (keyFile k) hashDirMixed :: Key -> FilePath hashDirMixed k = addTrailingPathSeparator $ take 2 dir drop 2 dir where - dir = take 4 $ concat $ map display_32bits_as_dir [a,b,c,d] + dir = take 4 $ display_32bits_as_dir =<< [a,b,c,d] ABCD (a,b,c,d) = md5 $ Str $ show k {- Generates a hash directory that is all lower case. -} diff --git a/Remote/S3real.hs b/Remote/S3real.hs index 135966903..baf570593 100644 --- a/Remote/S3real.hs +++ b/Remote/S3real.hs @@ -232,7 +232,7 @@ bucketKey r bucket k = S3Object bucket (bucketFile r k) "" [] L.empty - with no whitespace. Other characters are xml entity - encoded. -} iaMunge :: String -> String -iaMunge = concat . (map munge) +iaMunge = (>>= munge) where munge c | isAsciiUpper c || isAsciiLower c || isNumber c = [c] diff --git a/Utility.hs b/Utility.hs index 44c8cdd65..6dd7d329c 100644 --- a/Utility.hs +++ b/Utility.hs @@ -59,7 +59,7 @@ data CommandParam = Params String | Param String | File FilePath {- Used to pass a list of CommandParams to a function that runs - a command and expects Strings. -} toCommand :: [CommandParam] -> [String] -toCommand l = concat $ map unwrap l +toCommand = (>>= unwrap) where unwrap (Param s) = [s] unwrap (Params s) = filter (not . null) (split " " s) -- cgit v1.2.3