[move pretty printing functions from Logging.Logger to Logging.PrettyPrinter
martin.hofmann@uni-bamberg.de**20090126144723] hunk ./src/Logging.hs 4
-       module Logging.Logger
+       module Logging.Logger,
+       module Logging.PrettyPrinter
hunk ./src/Logging.hs 10
-
+import Logging.PrettyPrinter
hunk ./src/Logging/Logger.hs 14
-    
-    printResult,
+
hunk ./src/Logging/Logger.hs 30
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.IntMap as IM
-import qualified Data.IntSet as IS
+import Data.Maybe (maybeToList)
hunk ./src/Logging/Logger.hs 40
-import Data.Maybe (maybeToList)
-import Data.Time.Clock
-import Data.Time.Calendar
-import System.CPUTime
-import System.IO
-import System.Mem
hunk ./src/Logging/Logger.hs 41
-
hunk ./src/Logging/Logger.hs 43
+
hunk ./src/Logging/Logger.hs 77
-    
---instance Pretty Log where
---    pretty l = map showLogEntry (logs l) ++
---               map showLogEntry (maybeToList(lst l))
hunk ./src/Logging/Logger.hs 148
-              
+
+
+handle :: LogEntry -> LM ()
+handle (LE p l msg) =
+    do lvl <- getPriority
+       gll <- getGlobalLogLevel
+       when ((isPrefixOf gll l) && (lvl <= p)) $ tell (Log [] (Just (LE p l msg)))
+                     
hunk ./src/Logging/Logger.hs 168
---instance (Monad m) => ELog (ELT m)     
hunk ./src/Logging/Logger.hs 174
-handle :: LogEntry -> LM ()
-handle (LE p l msg) =
-    do lvl <- getPriority
-       gll <- getGlobalLogLevel
-       when ((isPrefixOf gll l) && (lvl <= p)) $ tell (Log [] (Just (LE p l msg)))
hunk ./src/Logging/Logger.hs 176
-
-date :: IO (Integer,Int,Int,Integer) -- :: (year,month,day,CPUTime)
-date = do
-       (y,m,d) <- getCurrentTime >>= return . toGregorian . utctDay
-       s       <- getCPUTime
-       return (y,m,d,s)
-
-showDate = date >>= \(y,m,d,s) ->
-             return $ (shows y) . (shows m). (shows d) $ show s
-
-printResult :: (Either String [[Dec]],Log) -> IO()
-printResult (r,l) = do 
-    file    <- showDate >>= \d -> return ("log/" ++ d ++ ".log")
-    fhandle <-openFile file AppendMode
-    printLog l  [fhandle,stdout]
-    case r of
-        Left  e -> mapM_ ((flip hPutStr)  ("UNCAUGHT ERROR: " ++ e)) [fhandle,stdout]
-        Right r -> printDecs r [fhandle,stdout]
-    hClose fhandle
-    
-                
-printLog :: Log -> [Handle] -> IO ()
-printLog logs handles = return () -- mapM_ (flip hPutDoc content) handles
-    where    
-    content = frame "Log Log Log Log Log Log Log" <$> pretty logs
-
-printDecs :: [[Dec]] -> [Handle] -> IO()
-printDecs decs handles = do
-    docs <- liftM vcat $ mapM printInQ (zip decs [1..])
-    let content = frame "Results Results Results" <$$> docs
-    mapM_ ((flip hPutDoc) content) handles
-
-printInQ :: ([Dec],Int) -> IO Doc    
-printInQ = \(d,i) -> (runQ.return) d >>= \p -> 
-                return $ indent 6 (text "HYPOTHESE" <+> int i <> colon) <$$>
-                         linebreak <> 
-                         vcat (map pretty p) <>
-                         linebreak 
-                         
-frame s = vsep [line,header s,line,softline]
-    where
-    line     = (text "*") <+>
-               hsep (replicate (colwidth -2) (text "-")) <+>
-               text  "*"
-    spaces   = ((colwidth) - (length s)) `div` 2 
-    colwidth =  72
-    header s = (text "|") <+> hsep (replicate spaces space) <+>
-               text s <+> hsep (replicate spaces space) <+> (text "|")    
-    
- 
hunk ./src/Logging/Logger.hs 183
-  
-set  l = braces $ align $ hcat $ punctuate comma l
-
-asMap (a,b) = 
-	lparen <> (pretty a) <+> ((text "->" ) <+> ( align (pretty b) <> rparen))
-	
-asRepl (a,b) = 
-	lparen <> (pretty a) <+> ((text "<~" ) <+> ( align (pretty b) <> rparen))
-
-
-
hunk ./src/Logging/Logger.hs 185
-				   vsep [ text "arg" <> int (i+1) <+> (as !! i) | i <- [0 .. (length as)-1]]
-
-
---------------------------------------------------------------------------------
--- Pretty Instances
---------------------------------------------------------------------------------
-
-instance Pretty Exp where
-    pretty = text.pprint
-    
-instance Pretty Pat where
-    pretty = text.pprint
-      
-instance Pretty Dec where
-    pretty = text.pprint
-    
-instance Pretty Name where
-    pretty = text.show
+                   vsep [ text "arg" <> int (i+1) <+> (as !! i) | i <- [0 .. (length as)-1]]
hunk ./src/Logging/Logger.hs 187
-instance (Pretty k, Pretty v) => Pretty (M.Map k v) where
-	pretty m = list $ map asMap (M.toList m)
-	
-instance (Pretty v) => Pretty (IM.IntMap v) where
-	pretty m = list $ map asMap (IM.toList m)
hunk ./src/Logging/Logger.hs 188
-instance (Pretty e) => Pretty (S.Set e) where
-	pretty s = semiBraces $ map pretty (S.toList s)
-	
-instance Pretty (IS.IntSet) where
-	pretty s = set $ map pretty (IS.toList s)
hunk ./src/Logging/PrettyPrinter.hs 2
-module Logging.PrettyPrinter  where
+module Logging.PrettyPrinter  (
hunk ./src/Logging/PrettyPrinter.hs 4
+    printResult, 
hunk ./src/Logging/PrettyPrinter.hs 6
+)where
+
+
+import qualified Data.Map as M
+import qualified Data.Set as S
+import qualified Data.IntMap as IM
+import qualified Data.IntSet as IS
+
+import Logging.Logger
hunk ./src/Logging/PrettyPrinter.hs 16
+import Data.Maybe (maybeToList)
+import Data.Time.Clock
+import Data.Time.Calendar
+import System.CPUTime
+import System.IO
+import System.Mem
+import Debug.Trace
+
hunk ./src/Logging/PrettyPrinter.hs 26
-import Data.List (intersperse)
hunk ./src/Logging/PrettyPrinter.hs 27
+    
+
+date :: IO (Integer,Int,Int,Integer) -- :: (year,month,day,CPUTime)
+date = do
+       (y,m,d) <- getCurrentTime >>= return . toGregorian . utctDay
+       s       <- getCPUTime
+       return (y,m,d,s)
+
+showDate = date >>= \(y,m,d,s) ->
+             return $ (shows y) . (shows m). (shows d) $ show s
+
+printResult :: (Either String [[Dec]],Log) -> IO()
+printResult (r,l) = do 
+    file    <- showDate >>= \d -> return ("log/" ++ d ++ ".log")
+    fhandle <-openFile file AppendMode
+    printLog l  [fhandle,stdout]
+    case r of
+        Left  e -> mapM_ ((flip hPutStr)  ("UNCAUGHT ERROR: " ++ e)) [fhandle,stdout]
+        Right r -> printDecs r [fhandle,stdout]
+    hClose fhandle
+    
+                
+printLog :: Log -> [Handle] -> IO ()
+printLog logs handles = return () -- mapM_ (flip hPutDoc content) handles
+    where    
+    content = frame "Log Log Log Log Log Log Log" <$> pretty logs
+
+printDecs :: [[Dec]] -> [Handle] -> IO()
+printDecs decs handles = do
+    docs <- liftM vcat $ mapM printInQ (zip decs [1..])
+    let content = frame "Results Results Results" <$$> docs
+    mapM_ ((flip hPutDoc) content) handles
+
+printInQ :: ([Dec],Int) -> IO Doc    
+printInQ = \(d,i) -> (runQ.return) d >>= \p -> 
+                return $ indent 6 (text "HYPOTHESE" <+> int i <> colon) <$$>
+                         linebreak <> 
+                         vcat (map pretty p) <>
+                         linebreak 
+                         
+frame s = vsep [line,header s,line,softline]
+    where
+    line     = (text "*") <+>
+               hsep (replicate (colwidth -2) (text "-")) <+>
+               text  "*"
+    spaces   = ((colwidth) - (length s)) `div` 2 
+    colwidth =  72
+    header s = (text "|") <+> hsep (replicate spaces space) <+>
+               text s <+> hsep (replicate spaces space) <+> (text "|")    
+    
+ 
+--------------------------------------------------------------------------------
+-- Pretty Helpers
+--------------------------------------------------------------------------------
+
+  
+set  l = braces $ align $ hcat $ punctuate comma l
+
+asMap (a,b) = 
+    lparen <> (pretty a) <+> ((text "->" ) <+> ( align (pretty b) <> rparen))
+    
+asRepl (a,b) = 
+    lparen <> (pretty a) <+> ((text "<~" ) <+> ( align (pretty b) <> rparen))
+
+
+
+--------------------------------------------------------------------------------
+-- Pretty Instances
+--------------------------------------------------------------------------------
hunk ./src/Logging/PrettyPrinter.hs 97
+instance Pretty Exp where
+    pretty = text.pprint
hunk ./src/Logging/PrettyPrinter.hs 100
+instance Pretty Pat where
+    pretty = text.pprint
+      
+instance Pretty Dec where
+    pretty = text.pprint
+    
+instance Pretty Name where
+    pretty = text.show
hunk ./src/Logging/PrettyPrinter.hs 109
+instance (Pretty k, Pretty v) => Pretty (M.Map k v) where
+    pretty m = list $ map asMap (M.toList m)
hunk ./src/Logging/PrettyPrinter.hs 112
---instance (Pretty p) => Pretty [p] where
---    pretty u =  ["[" ++ ((concat.(intersperse ",")) (map view u)) ++ "]"]
---
---viewlist :: (Pretty e) => [e] -> String
---viewlist = concatMap view
+instance (Pretty v) => Pretty (IM.IntMap v) where
+    pretty m = list $ map asMap (IM.toList m)
hunk ./src/Logging/PrettyPrinter.hs 115
+instance (Pretty e) => Pretty (S.Set e) where
+    pretty s = semiBraces $ map pretty (S.toList s)
+    
+instance Pretty (IS.IntSet) where
+    pretty s = set $ map pretty (IS.toList s)