Fix more warnings
[ghc-hetmet.git] / utils / nofib-analyse / Main.hs
index 3405add..c0c2903 100644 (file)
@@ -15,7 +15,6 @@ import Text.Html hiding (cols, rows, (!))
 import qualified Text.Html as Html ((!))
 import qualified Data.Map as Map
 import Data.Map (Map)
-import System.Console.GetOpt
 import System.Exit      ( exitWith, ExitCode(..) )
 
 import Control.Monad
@@ -32,14 +31,11 @@ import Data.List
 die :: String -> IO a
 die s = hPutStr stderr s >> exitWith (ExitFailure 1)
 
-usageHeader :: String
-usageHeader = "usage: nofib-analyse [OPTION...] <logfile1> <logfile2> ..."
-
 main :: IO ()
 main = do
 
  when (not (null cmdline_errors) || OptHelp `elem` flags) $
-      die (concat cmdline_errors ++ usageInfo usageHeader argInfo)
+      die (concat cmdline_errors ++ usage)
 
  let { html  = OptHTMLOutput  `elem` flags;
        latex = OptLaTeXOutput `elem` flags;
@@ -337,15 +333,19 @@ findBest stuff@(Result base : rest)
         unPcnt (_ : rest)                = unPcnt rest
 -}
 
+logHeaders :: [String] -> HtmlTable
 logHeaders ss
   = besides (map (\s -> (td <! [align "right", width "100"] << bold << s)) ss)
 
+mkTable :: HtmlTable -> Html
 mkTable t = table <! [cellspacing 0, cellpadding 0, border 0] << t
 
+tabHeader :: [String] -> HtmlTable
 tabHeader ss
   =   (td <! [align "left", width "100"] << bold << "Program")
   <-> logHeaders ss
 
+multiTabHeader :: [String] -> HtmlTable
 multiTabHeader ss
   =   (td <! [align "left", width "100"] << bold << "Program")
   <-> (td <! [align "left", width "100"] << bold << "Module")
@@ -355,7 +355,7 @@ multiTabHeader ss
 
 calcColor :: Int -> String
 calcColor p | p >= 0    = "#"     ++ (showHex red 2 "0000")
-              | otherwise = "#0000" ++ (showHex blue 2 "")
+            | otherwise = "#0000" ++ (showHex blue 2 "")
         where red  = p * 255 `div` 100
               blue = (-p) * 255 `div` 100
 
@@ -586,10 +586,10 @@ calc_result rts get_maybe_a get_stat result_ok (prog,base_r) =
         base_stat = get_stat base_r
 
         just_result Nothing  s = RunFailed s
-        just_result (Just a) s = toBox a
+        just_result (Just a) _ = toBox a
 
-        percentage Nothing   s base = RunFailed s
-        percentage (Just a)  s base = Percentage
+        percentage Nothing   s _    = RunFailed s
+        percentage (Just a)  _ base = Percentage
                                          (convert_to_percentage base a)
 -----------------------------------------------------------------------------
 -- Calculating geometric means and standard deviations
@@ -662,22 +662,23 @@ class Num a => Result a where
 -- We assume an Int is a size, and print it in kilobytes.
 
 instance Result Int where
-        convert_to_percentage 0 size = 100
-        convert_to_percentage base size = (fromIntegral size / fromIntegral base) * 100
+    convert_to_percentage 0    _    = 100
+    convert_to_percentage base size
+        = (fromIntegral size / fromIntegral base) * 100
 
-        toBox = BoxInt
+    toBox = BoxInt
 
 instance Result Integer where
-        convert_to_percentage 0 size = 100
-        convert_to_percentage base size = (fromInteger size / fromInteger base) * 100
-        toBox = BoxInteger
-
+    convert_to_percentage 0    _    = 100
+    convert_to_percentage base size
+        = (fromInteger size / fromInteger base) * 100
+    toBox = BoxInteger
 
 instance Result Float where
-        convert_to_percentage 0.0 size = 100.0
-        convert_to_percentage base size = size / base * 100
+    convert_to_percentage 0.0  _    = 100.0
+    convert_to_percentage base size = size / base * 100
 
-        toBox = BoxFloat
+    toBox = BoxFloat
 
 -- -----------------------------------------------------------------------------
 -- BoxValues
@@ -693,20 +694,16 @@ data BoxValue
 
 showBox :: BoxValue -> String
 showBox (RunFailed stat) = show_stat stat
-showBox (Percentage f)   = show_pcntage f
+showBox (Percentage f)   = printf "%+.1f%%" (f-100)
 showBox (BoxFloat f)     = printf "%.2f" f
 showBox (BoxInt n)       = show (n `div` 1024) ++ "k"
 showBox (BoxInteger n)   = show (n `div` 1024) ++ "k"
 showBox (BoxString s)    = s
 
-instance Show BoxValue where { show = showBox }
-
-show_pcntage n = show_float_signed (n-100) ++ "%"
-
-show_float_signed n
-  | n >= 0    = printf "+%.1f" n
-  | otherwise = printf "%.1f" n
+instance Show BoxValue where
+    show = showBox
 
+show_stat :: Status -> String
 show_stat Success     = "(no result)"
 show_stat WrongStdout = "(stdout)"
 show_stat WrongStderr = "(stderr)"