From f25c3d8410c438a3a0e0b8abaf5d6380c008f6f2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 9 Mar 2007 21:39:59 +0000 Subject: [PATCH] overview.hs helps generate OVERVIEW --- overview.hs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 overview.hs diff --git a/overview.hs b/overview.hs new file mode 100644 index 000000000..36eaaf2d4 --- /dev/null +++ b/overview.hs @@ -0,0 +1,33 @@ +-- overview.hs - update an OVERVIEW file +-- +-- OVERVIEW begins with a manually updated list of modules; below that we +-- generate a list of filename, function, type entries. Useful for getting +-- the big picture and refactoring. + +import System +import System.Process +import IO +import Data.List +import Text.Printf + +main = do + old <- readFile "OVERVIEW" + let preamble = takeWhile ((> 0) . length) $ lines old + putStr $ unlines preamble + let modules = concat $ map ((++ ".hs ") . dropWhile (== ' ')) preamble + let grep = "grep -H '^\\w[^=]*::' " ++ modules + (inp, out, err, pid) <- runInteractiveCommand grep + grepoutput <- hGetContents out + let groups = groupBy (\a b -> samefile a b) $ lines grepoutput + sequence $ map printgroup groups + putStr "\n" + +printgroup ls = do putStr "\n"; sequence $ map printline ls + +printline l = + putStrLn $ printf "%-22s %-40s %s" (file++":") code typedecl + where + (file, rest) = break (== ':') l + (code, typedecl) = break (== ':') $ tail rest + +samefile a b = ((takeWhile (/= ':') a) ++ ":") `isPrefixOf` b