hdocs-0.4.1.1: tests/Test.hs
module Main (
main
) where
import Control.Monad
import Control.Monad.Error
import qualified Data.Map as M
import System.Exit
import HDocs.Module
import HDocs.Haddock
-- | This is main function
main :: IO ()
main = runErrorT main' >>= either (\e -> putStrLn e >> exitFailure) (const exitSuccess) where
main' :: ErrorT String IO ()
main' = do
sdocs <- fmt $ liftM snd $ readSource [] "tests/HelpTest.hs"
check "Documentation for file: Test.hs, test"
(M.lookup "test" sdocs == Just "This is test function with documentation")
edocs <- fmt $ moduleDocs [] "Prelude"
check "Documentation for installed module: Prelude.null"
(M.lookup "null" edocs == Just "Test whether a list is empty.")
where
check str p = unless p $ throwError str
fmt = liftM formatDocs