]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - ImplantFile.hs
Cosmetic changes suggested by hlint
[Lucu.git] / ImplantFile.hs
index ae749b9886c5a7422cd25bceb2137a83debb796f..1d7d43d8ce21f51666bb53b3b4652d94f37de063 100644 (file)
@@ -78,11 +78,11 @@ main :: IO ()
 main = withOpenSSL $
        do (opts, sources, errors) <- return . getOpt Permute options =<< getArgs
 
-          when (not $ null errors)
+          unless (null errors)
                    $ do mapM_ putStr errors
                         exitWith $ ExitFailure 1
 
-          when (any (\ x -> x == OptHelp) opts)
+          when (any (== OptHelp) opts)
                    $ do printUsage
                         exitWith ExitSuccess
 
@@ -106,7 +106,7 @@ generateHaskellSource opts srcFile
          output   <- openOutput opts
          eTag     <- getETag opts input
 
-         let compParams  = defaultCompressParams { compressLevel = BestCompression }
+         let compParams  = defaultCompressParams { compressLevel = bestCompression }
              gzippedData = compressWith compParams input
              originalLen = L.length input
              gzippedLen  = L.length gzippedData
@@ -371,12 +371,12 @@ getSymbolName opts modName
                                             _            -> False) opts
           -- モジュール名をピリオドで分割した時の最後の項目の先頭文字を
           -- 小文字にしたものを使ふ。
-          defaultSymName = mkDefault modName
-          mkDefault      = headToLower . getLastComp
-          headToLower    = \ str -> case str of
-                                      []     -> error "module name must not be empty"
-                                      (x:xs) -> toLower x : xs
-          getLastComp    = reverse . fst . break (== '.') . reverse
+          defaultSymName  = mkDefault modName
+          mkDefault       = headToLower . getLastComp
+          headToLower str = case str of
+                              []     -> error "module name must not be empty"
+                              (x:xs) -> toLower x : xs
+          getLastComp     = reverse . fst . break (== '.') . reverse
       in
         case symNameOpts of
           []                      -> return defaultSymName
@@ -400,8 +400,8 @@ getMIMEType opts srcFile
 
 getLastModified :: FilePath -> IO UTCTime
 getLastModified "-"   = getCurrentTime
-getLastModified fpath = getFileStatus fpath
-                        >>= return . posixSecondsToUTCTime . fromRational . toRational . modificationTime
+getLastModified fpath = fmap (posixSecondsToUTCTime . fromRational . toRational . modificationTime)
+                        $ getFileStatus fpath
 
 
 getETag :: [CmdOpt] -> Lazy.ByteString -> IO String
@@ -411,25 +411,26 @@ getETag opts input
                                       _         -> False) opts
       in
         case eTagOpts of
-          []               -> getDigestByName "SHA1" >>= return . mkETagFromInput . fromJust
+          []               -> fmap (mkETagFromInput . fromJust) (getDigestByName "SHA1")
           (OptETag str):[] -> return str
           _                -> error "too many --etag options."
     where
       mkETagFromInput :: Digest -> String
-      mkETagFromInput sha1 = "SHA-1:" ++ (toHex $ digestLBS sha1 input)
+      mkETagFromInput sha1 = "SHA-1:" ++ toHex (digestLBS sha1 input)
 
-      toHex :: [Char] -> String
-      toHex []     = ""
-      toHex (x:xs) = hexByte (fromEnum x) ++ toHex xs
+      toHex :: String -> String
+      toHex = foldr ((++) . hexByte . fromEnum) ""
 
       hexByte :: Int -> String
       hexByte n
-          = hex4bit ((n `shiftR` 4) .&. 0x0F) : hex4bit (n .&. 0x0F) : []
+          = [ hex4bit ((n `shiftR` 4) .&. 0x0F)
+            , hex4bit ( n             .&. 0x0F)
+            ]
 
       hex4bit :: Int -> Char
       hex4bit n
-          | n < 10    = (chr $ ord '0' + n     )
-          | n < 16    = (chr $ ord 'a' + n - 10)
+          | n < 10    = chr $ ord '0' + n
+          | n < 16    = chr $ ord 'a' + n - 10
           | otherwise = undefined