Skip to content

Instantly share code, notes, and snippets.

@cmoore
Created July 2, 2009 18:58
Show Gist options
  • Save cmoore/139644 to your computer and use it in GitHub Desktop.
Save cmoore/139644 to your computer and use it in GitHub Desktop.
module Doc where
import Control.Monad
import System.Directory
qualify :: FilePath -> IO String
qualify x = liftM (\y ->
y ++ "/.cabal/share/doc/" ++ x ++ "/html/doc-index.html"
) getHomeDirectory
docPath :: IO String
docPath =
liftM (++ "/.cabal/share/doc") getHomeDirectory
-- Get the directories under ~/.cabal/share/doc, excluding . and ..
docDirs :: IO [ FilePath ]
docDirs =
liftM (filter zx) $ docPath >>= getDirectoryContents
where zx (x:_) =
case x of
'.' -> False
_ -> True
-- I'm sure that there is a much more elegant way to do this.
docIndexFiles :: IO [ FilePath ]
docIndexFiles = do
px <- docDirs
lx <- mapM qualify px
filterM doesFileExist lx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment