more pointless monadic golfing

This commit is contained in:
Joey Hess 2011-05-16 14:49:28 -04:00
parent 57428c356e
commit 760cde28b6
4 changed files with 4 additions and 5 deletions

View file

@ -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

View file

@ -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. -}

View file

@ -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]

View file

@ -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)