module Haddock.Types (
module Haddock.Types
, HsDocString, LHsDocString
) where
import Control.Exception
import Control.Arrow
import Data.Typeable
import Data.Map (Map)
import qualified Data.Map as Map
import GHC hiding (NoLink)
import Name
type IfaceMap = Map Module Interface
type InstIfaceMap = Map Module InstalledInterface
type DocMap = Map Name (Doc DocName)
type SrcMap = Map PackageId FilePath
type Decl = LHsDecl Name
type GhcDocHdr = Maybe LHsDocString
type DocPaths = (FilePath, Maybe FilePath)
data ifaceRnDocMap :: Map Name (DocForDecl DocName)Interface = Interface
{
ifaceMod :: Module
, ifaceOrigFilename :: FilePath
, ifaceInfo :: !(HaddockModInfo Name)
, ifaceDoc :: !(Maybe (Doc Name))
, ifaceRnDoc :: Maybe (Doc DocName)
, ifaceOptions :: ![DocOption]
, ifaceDeclMap :: Map Name DeclInfo
, ifaceRnDocMap :: Map Name (DocForDecl DocName)
, ifaceSubMap :: Map Name [Name]
, ifaceExportItems :: ![ExportItem Name]
, ifaceRnExportItems :: [ExportItem DocName]
, ifaceExports :: ![Name]
, ifaceVisibleExports :: ![Name]
, ifaceInstances :: ![Instance]
, ifaceInstanceDocMap :: Map Name (Doc Name)
, ifaceHaddockCoverage :: (Int,Int)
, ifaceTcSource :: TypecheckedSource
}
data instDocMap :: Map Name (DocForDecl Name)InstalledInterface = InstalledInterface
{
instMod :: Module
, instInfo :: HaddockModInfo Name
, instDocMap :: Map Name (DocForDecl Name)
, instExports :: [Name]
, instVisibleExports :: [Name]
, instOptions :: [DocOption]
, instSubMap :: Map Name [Name]
}
toInstalledIface :: Interface -> InstalledInterface
toInstalledIface interface = InstalledInterface
{ instMod = ifaceMod :: Interface -> ModuleifaceMod interface :: Interfaceinterface
, instInfo = ifaceInfo :: Interface -> HaddockModInfo NameifaceInfo interface :: Interfaceinterface
, instDocMap = fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap unrenameDocForDecl :: DocForDecl DocName -> DocForDecl NameunrenameDocForDecl ($) :: (a -> b) -> a -> b$ ifaceRnDocMap :: Interface -> Map Name (DocForDecl DocName)ifaceRnDocMap interface :: Interfaceinterface
, instExports = ifaceExports :: Interface -> [Name]ifaceExports interface :: Interfaceinterface
, instVisibleExports = ifaceVisibleExports :: Interface -> [Name]ifaceVisibleExports interface :: Interfaceinterface
, instOptions = ifaceOptions :: Interface -> [DocOption]ifaceOptions interface :: Interfaceinterface
, instSubMap = ifaceSubMap :: Interface -> Map Name [Name]ifaceSubMap interface :: Interfaceinterface
}
data expItemSubDocs :: [(name, DocForDecl name)]ExportItem name
= ExportDecl
{
expItemDecl :: LHsDecl name
, expItemMbDoc :: DocForDecl name
, expItemSubDocs :: [(name, DocForDecl name)]
, expItemInstances :: [DocInstance name]
}
| ExportNoDecl
{ expItemName :: name
, expItemSubs :: [name]
}
| ExportGroup
{
expItemSectionLevel :: Int
, expItemSectionId :: String
, expItemSectionText :: Doc name
}
| ExportDoc (Doc name)
| ExportModule Module
type DeclInfo = (Decl, DocForDecl Name, [(Name, DocForDecl Name)])
type FnArgsDoc name = Map Int (Doc name)
type DocForDecl name = (Maybe (Doc name), FnArgsDoc name)
noDocForDecl :: DocForDecl name
noDocForDecl = (Nothing :: Maybe aNothing, empty :: Map k aMap.empty)
unrenameDocForDecl :: DocForDecl DocName -> DocForDecl Name
unrenameDocForDecl (mbDoc, fnArgsDoc) =
(fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap unrenameDoc :: Doc DocName -> Doc NameunrenameDoc mbDoc :: Maybe (Doc DocName)mbDoc, fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap unrenameDoc :: Doc DocName -> Doc NameunrenameDoc fnArgsDoc :: FnArgsDoc DocNamefnArgsDoc)
type LinkEnv = Map Name Module
data DocName
= Documented Name Module
| Undocumented Name
deriving D:Eq :: (a -> a -> Bool) -> (a -> a -> Bool) -> T:Eq aEq
instance D:NamedThing :: (a -> OccName) -> (a -> Name) -> T:NamedThing aNamedThing DocName where
getName (Documented name _) = name :: Namename
getName (Undocumented name) = name :: Namename
type DocInstance name = (InstHead name, Maybe (Doc name))
type InstHead name = ([HsPred name], name, [HsType name])
type LDoc id = Located (Doc id)
data Doc id
= DocEmpty
| DocAppend (Doc id) (Doc id)
| DocString String
| DocParagraph (Doc id)
| DocIdentifier [id]
| DocModule String
| DocEmphasis (Doc id)
| DocMonospaced (Doc id)
| DocUnorderedList [Doc id]
| DocOrderedList [Doc id]
| DocDefList [(Doc id, Doc id)]
| DocCodeBlock (Doc id)
| DocURL String
| DocPic String
| DocAName String
| DocExamples [Example]
deriving (D:Eq :: (a -> a -> Bool) -> (a -> a -> Bool) -> T:Eq aEq, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow, D:Functor ::
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a)
-> T:Functor fFunctor)
unrenameDoc :: Doc DocName -> Doc Name
unrenameDoc = fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap getName :: NamedThing a => a -> NamegetName
data exampleExpression :: StringExample = Example
{ exampleExpression :: String
, exampleResult :: [String]
} deriving (D:Eq :: (a -> a -> Bool) -> (a -> a -> Bool) -> T:Eq aEq, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
exampleToString :: Example -> String
exampleToString (Example expression result) =
">>> " (++) :: [a] -> [a] -> [a]++ expression :: Stringexpression (++) :: [a] -> [a] -> [a]++ "\n" (++) :: [a] -> [a] -> [a]++ unlines :: [String] -> Stringunlines result :: [String]result
data markupUnorderedList :: [a] -> aDocMarkup 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
, markupPic :: String -> a
, markupExample :: [Example] -> a
}
data hmi_description :: Maybe (Doc name)HaddockModInfo name = HaddockModInfo
{ hmi_description :: Maybe (Doc name)
, hmi_portability :: Maybe String
, hmi_stability :: Maybe String
, hmi_maintainer :: Maybe String
}
emptyHaddockModInfo :: HaddockModInfo a
emptyHaddockModInfo = HaddockModInfo
{ hmi_description = Nothing :: Maybe aNothing
, hmi_portability = Nothing :: Maybe aNothing
, hmi_stability = Nothing :: Maybe aNothing
, hmi_maintainer = Nothing :: Maybe aNothing
}
data DocOption
= OptHide
| OptPrune
| OptIgnoreExports
| OptNotHome
deriving (D:Eq :: (a -> a -> Bool) -> (a -> a -> Bool) -> T:Eq aEq, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
data Qualification
= NoQual
| FullQual
| LocalQual (Maybe Module)
| RelativeQual (Maybe Module)
type ErrMsg = String
newtype runWriter :: (a, [ErrMsg])ErrMsgM a = Writer { runWriter :: (a, [ErrMsg]) }
instance D:Functor ::
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a)
-> T:Functor fFunctor ErrMsgM where
fmap f (Writer (a, msgs)) = Writer :: (a, [ErrMsg]) -> ErrMsgM aWriter (f :: a -> bf a :: aa, msgs :: [ErrMsg]msgs)
instance D:Monad ::
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> (forall a. String -> m a)
-> T:Monad mMonad ErrMsgM where
return a = Writer :: (a, [ErrMsg]) -> ErrMsgM aWriter (a :: aa, [] :: [a][])
m >>= k = Writer :: (a, [ErrMsg]) -> ErrMsgM aWriter ($) :: (a -> b) -> a -> b$ let
(a, w) = runWriter :: ErrMsgM a -> (a, [ErrMsg])runWriter m :: ErrMsgM am
(b, w') = runWriter :: ErrMsgM a -> (a, [ErrMsg])runWriter (k :: a -> ErrMsgM bk a :: aa)
in (b :: bb, w :: [ErrMsg]w (++) :: [a] -> [a] -> [a]++ w' :: [ErrMsg]w')
tell :: [ErrMsg] -> ErrMsgM ()
tell w = Writer :: (a, [ErrMsg]) -> ErrMsgM aWriter ((), w :: [ErrMsg]w)
data HaddockException = HaddockException String deriving D:Typeable :: (a -> TypeRep) -> T:Typeable aTypeable
instance D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow HaddockException where
show (HaddockException str) = str :: Stringstr
throwE :: String -> a
instance D:Exception ::
(Typeable e, Show e) =>
(e -> SomeException) -> (SomeException -> Maybe e) -> T:Exception eException HaddockException
throwE str = throw :: Exception e => e -> athrow (HaddockException :: String -> HaddockExceptionHaddockException str :: Stringstr)
newtype runWriterGhc :: Ghc (a, [ErrMsg])ErrMsgGhc a = WriterGhc { runWriterGhc :: (Ghc (a, [ErrMsg])) }
liftGhcToErrMsgGhc :: Ghc a -> ErrMsgGhc a
liftGhcToErrMsgGhc = WriterGhc :: Ghc (a, [ErrMsg]) -> ErrMsgGhc aWriterGhc (.) :: (b -> c) -> (a -> b) -> a -> c. fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap (\a->(a :: aa,[] :: [a][]))
liftErrMsg :: ErrMsgM a -> ErrMsgGhc a
liftErrMsg = WriterGhc :: Ghc (a, [ErrMsg]) -> ErrMsgGhc aWriterGhc (.) :: (b -> c) -> (a -> b) -> a -> c. return :: Monad m => forall a. a -> m areturn (.) :: (b -> c) -> (a -> b) -> a -> c. runWriter :: ErrMsgM a -> (a, [ErrMsg])runWriter
instance D:Functor ::
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a)
-> T:Functor fFunctor ErrMsgGhc where
fmap f (WriterGhc x) = WriterGhc :: Ghc (a, [ErrMsg]) -> ErrMsgGhc aWriterGhc (fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap (first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)first f :: a -> bf) x :: Ghc (a, [ErrMsg])x)
instance D:Monad ::
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> (forall a. String -> m a)
-> T:Monad mMonad ErrMsgGhc where
return a = WriterGhc :: Ghc (a, [ErrMsg]) -> ErrMsgGhc aWriterGhc (return :: Monad m => forall a. a -> m areturn (a :: aa, [] :: [a][]))
m >>= k = WriterGhc :: Ghc (a, [ErrMsg]) -> ErrMsgGhc aWriterGhc ($) :: (a -> b) -> a -> b$ runWriterGhc :: ErrMsgGhc a -> Ghc (a, [ErrMsg])runWriterGhc m :: ErrMsgM am (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>= \ (a, msgs1) ->
fmap :: Functor f => forall a b. (a -> b) -> f a -> f bfmap (second :: Arrow a => forall b c d. a b c -> a (d, b) (d, c)second (msgs1 :: [ErrMsg]msgs1 (++) :: [a] -> [a] -> [a]++)) (runWriterGhc :: ErrMsgGhc a -> Ghc (a, [ErrMsg])runWriterGhc (k :: a -> ErrMsgM bk a :: aa))