-- -- | Generate the initial @index state -- import System.Cmd import System.Directory import Data.List main :: IO () main = do system $ "wget -nc -r -l 1 "++ "http://haskell.org/ghc/docs/latest/html/libraries/doc-index.html" dir <- getCurrentDirectory let filesdir = dir ++ "/haskell.org/ghc/docs/latest/html/libraries/" files <- getDirectoryContents filesdir let docfiles = filter ("doc-index-"`isPrefixOf`) files assocs <- fmap concat $ mapM getAssocs $ map (filesdir++) docfiles writeFile "../State/haddock" $ unlines $ map show assocs getAssocs :: FilePath -> IO [(String,[String])] getAssocs file = do cont <- lines `fmap` readFile file let isKey str = "> String clean ('&':'a':'m':'p':';':xs) = '&':clean xs clean ('&':'l':'t':';':xs) = '<':clean xs clean ('&':'g':'t':';':xs) = '>':clean xs clean (x:xs) = x:clean xs clean [] = []