Created
July 2, 2009 18:58
-
-
Save cmoore/139644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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