module Haddock.Types where
import Haddock.GHC.Utils
import Haddock.DocName
import Data.Map (Map)
import qualified Data.Map as Map
import GHC hiding (NoLink)
import Outputable
import OccName
import Name
data DocOption
= OptHide
| OptPrune
| OptIgnoreExports
| OptNotHome
deriving (Eq, Show)
data ExportItem name
= ExportDecl {
expItemDecl :: LHsDecl name,
expItemMbDoc :: Maybe (HsDoc name),
expItemInstances :: [InstHead name]
}
| ExportNoDecl {
expItemName :: Name,
expItemLinkTarget :: name,
expItemSubs :: [name]
}
| ExportGroup {
expItemSectionLevel :: Int,
expItemSectionId :: String,
expItemSectionText :: HsDoc name
}
| ExportDoc (HsDoc name)
| ExportModule Module
type InstHead name = ([HsPred name], name, [HsType name])
type ModuleMap = Map Module Interface
type DocMap = Map Name (HsDoc DocName)
type LinkEnv = Map Name Module
data GhcModule = GhcModule {
ghcModule :: Module,
ghcFilename :: FilePath,
ghcMbDocOpts :: Maybe String,
ghcHaddockModInfo :: HaddockModInfo Name,
ghcMbDoc :: Maybe (HsDoc Name),
ghcGroup :: HsGroup Name,
ghcMbExports :: Maybe [LIE Name],
ghcExportedNames :: [Name],
ghcDefinedNames :: [Name],
ghcNamesInScope :: [Name],
ghcInstances :: [Instance]
}
data Interface = Interface {
ifaceMod :: Module,
ifaceOrigFilename :: FilePath,
ifaceInfo :: HaddockModInfo Name,
ifaceDoc :: Maybe (HsDoc Name),
ifaceRnDoc :: Maybe (HsDoc DocName),
ifaceOptions :: [DocOption],
ifaceDeclMap :: Map Name (LHsDecl Name, Maybe (HsDoc Name)),
ifaceRnDocMap :: Map Name (HsDoc DocName),
ifaceExportItems :: [ExportItem Name],
ifaceRnExportItems :: [ExportItem DocName],
ifaceEnv :: Map OccName Name,
ifaceLocals :: [Name],
ifaceExports :: [Name],
ifaceVisibleExports :: [Name],
ifaceSubMap :: Map Name [Name],
ifaceInstances :: [Instance]
}
data InstalledInterface = InstalledInterface {
instMod :: Module,
instInfo :: HaddockModInfo Name,
instDocMap :: Map Name (HsDoc DocName),
instExports :: [Name],
instVisibleExports :: [Name]
}
toInstalledIface :: Interface -> InstalledInterface
toInstalledIface interface = InstalledInterface {
instMod = ifaceMod interface,
instInfo = ifaceInfo interface,
instDocMap = ifaceRnDocMap interface,
instExports = ifaceExports interface,
instVisibleExports = ifaceVisibleExports interface
}
data DocMarkup id a = Markup {
markupEmpty :: a,
markupString :: String -> a,
markupParagraph :: a -> a,
markupAppend :: a -> a -> a,
markupIdentifier :: [id] -> a,
markupModule :: String -> a,
markupEmphasis :: a -> a,
markupMonospaced :: a -> a,
markupUnorderedList :: [a] -> a,
markupOrderedList :: [a] -> a,
markupDefList :: [(a,a)] -> a,
markupCodeBlock :: a -> a,
markupURL :: String -> a,
markupAName :: String -> a
}
type ErrMsg = String
newtype ErrMsgM a = Writer { runWriter :: (a, [ErrMsg]) }
instance Monad ErrMsgM where
return a = Writer (a, [])
m >>= k = Writer $ let
(a, w) = runWriter m
(b, w') = runWriter (k a)
in (b, w ++ w')
tell :: [ErrMsg] -> ErrMsgM ()
tell w = Writer ((), w)