overview.hs helps generate OVERVIEW
This commit is contained in:
parent
328d198559
commit
f25c3d8410
33
overview.hs
Normal file
33
overview.hs
Normal file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user