more pointless monadic golfing
This commit is contained in:
parent
57428c356e
commit
760cde28b6
4 changed files with 4 additions and 5 deletions
|
@ -577,8 +577,7 @@ encodeGitFile s = foldl (++) "\"" (map echar s) ++ "\""
|
||||||
e_num c = showoctal $ ord c
|
e_num c = showoctal $ ord c
|
||||||
-- unicode character is decomposed to
|
-- unicode character is decomposed to
|
||||||
-- Word8s and each is shown in octal
|
-- Word8s and each is shown in octal
|
||||||
e_utf c = concat $ map showoctal $
|
e_utf c = showoctal =<< (encode [c] :: [Word8])
|
||||||
(encode [c] :: [Word8])
|
|
||||||
|
|
||||||
{- for quickcheck -}
|
{- for quickcheck -}
|
||||||
prop_idempotent_deencode :: String -> Bool
|
prop_idempotent_deencode :: String -> Bool
|
||||||
|
|
|
@ -175,7 +175,7 @@ prop_idempotent_fileKey s = Just k == fileKey (keyFile k)
|
||||||
hashDirMixed :: Key -> FilePath
|
hashDirMixed :: Key -> FilePath
|
||||||
hashDirMixed k = addTrailingPathSeparator $ take 2 dir </> drop 2 dir
|
hashDirMixed k = addTrailingPathSeparator $ take 2 dir </> drop 2 dir
|
||||||
where
|
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
|
ABCD (a,b,c,d) = md5 $ Str $ show k
|
||||||
|
|
||||||
{- Generates a hash directory that is all lower case. -}
|
{- Generates a hash directory that is all lower case. -}
|
||||||
|
|
|
@ -232,7 +232,7 @@ bucketKey r bucket k = S3Object bucket (bucketFile r k) "" [] L.empty
|
||||||
- with no whitespace. Other characters are xml entity
|
- with no whitespace. Other characters are xml entity
|
||||||
- encoded. -}
|
- encoded. -}
|
||||||
iaMunge :: String -> String
|
iaMunge :: String -> String
|
||||||
iaMunge = concat . (map munge)
|
iaMunge = (>>= munge)
|
||||||
where
|
where
|
||||||
munge c
|
munge c
|
||||||
| isAsciiUpper c || isAsciiLower c || isNumber c = [c]
|
| isAsciiUpper c || isAsciiLower c || isNumber c = [c]
|
||||||
|
|
|
@ -59,7 +59,7 @@ data CommandParam = Params String | Param String | File FilePath
|
||||||
{- Used to pass a list of CommandParams to a function that runs
|
{- Used to pass a list of CommandParams to a function that runs
|
||||||
- a command and expects Strings. -}
|
- a command and expects Strings. -}
|
||||||
toCommand :: [CommandParam] -> [String]
|
toCommand :: [CommandParam] -> [String]
|
||||||
toCommand l = concat $ map unwrap l
|
toCommand = (>>= unwrap)
|
||||||
where
|
where
|
||||||
unwrap (Param s) = [s]
|
unwrap (Param s) = [s]
|
||||||
unwrap (Params s) = filter (not . null) (split " " s)
|
unwrap (Params s) = filter (not . null) (split " " s)
|
||||||
|
|
Loading…
Reference in a new issue