使用cabal构建haddock文档时出错

时间:2012-10-31 08:17:31

标签: haskell cabal haddock

我目前正在Haskell上开发small application。我已经记录了main。但cabal haddock --executables显示错误:

Running Haddock for XComposeChecker-0.1...
Preprocessing executables for XComposeChecker-0.1...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: rts-1.0
haddock coverage for ./XComposeChecker.hs:    8/13  62%
Warning: Couldn't find TyThing for exported Main.main: main:Main.main; not documenting.
haddock coverage for dist/build/tmp3599/./Main.hs:     1/2  50%
Warning: Main: could not find link destinations for:
    Main.main
Documentation created: dist/doc/html/XComposeChecker/checker/index.html

Main.hs本身:

import Text.ParserCombinators.Parsec
import System.Directory
import System.FilePath

import XComposeChecker

-- | Main
main = do
         homedir <- getHomeDirectory
         result <- parseFromFile parseXComposeFile (joinPath [homedir, ".XCompose"])
         print result

为什么haddock无法找到main的文档?

ghc-7.0.4上使用cabal-1.10.2.0haddock-2.9.2Fedora 17

1 个答案:

答案 0 :(得分:3)

Haddock文档必须附加到类型签名。试试这个:

-- | Main
main :: IO ()
main = do
    print 3

添加:还需要添加:

module Main(main) where

Main.hs的开头,允许haddock查找并记录main函数。