{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wwarn #-}
module Haddock.Interface.LexParseRn
( processDocString
, processDocStringParas
, processDocStringsParas
, processModuleHeader
) where
import Control.Arrow
import Control.Monad
import Control.Monad.State.Strict
import Data.Functor
import Data.List (maximumBy, (\\))
import Data.Ord
import qualified Data.Set as Set
import GHC
import GHC.Data.EnumSet as EnumSet
import GHC.Data.FastString (unpackFS)
import GHC.Driver.Session
import qualified GHC.LanguageExtensions as LangExt
import GHC.Parser.Lexer (ParserOpts)
import GHC.Parser.PostProcess
import GHC.Types.Avail
import GHC.Types.Name
import GHC.Types.Name.Reader
import GHC.Types.Name.Set
import GHC.Utils.Misc ((<||>))
import GHC.Utils.Outputable (Outputable (ppr), SDocContext, renderWithContext)
import qualified GHC.Utils.Outputable as Outputable
import Haddock.Interface.ParseModuleHeader
import Haddock.Parser
import Haddock.Types
processDocStringsParas
:: MonadIO m
=> ParserOpts
-> SDocContext
-> Maybe Package
-> [HsDoc GhcRn]
-> IfM m (MDoc Name)
processDocStringsParas :: forall (m :: Type -> Type).
MonadIO m =>
ParserOpts
-> SDocContext
-> Maybe Package
-> [HsDoc GhcRn]
-> IfM m (MDoc Name)
processDocStringsParas ParserOpts
parserOpts SDocContext
sDocContext Maybe Package
pkg [HsDoc GhcRn]
hdss =
(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name)
forall (f :: Type -> Type) a b c d.
Functor f =>
(DocH a b -> f (DocH c d)) -> MetaDoc a b -> f (MetaDoc c d)
overDocF (SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename SDocContext
sDocContext (Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. (a -> b) -> a -> b
$ WithHsDocIdentifiers [HsDocString] GhcRn -> Renamer
forall a. WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer WithHsDocIdentifiers [HsDocString] GhcRn
hds) (MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name)
forall a b. (a -> b) -> a -> b
$ ParserOpts
-> Maybe Package
-> Package
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
forall mod.
ParserOpts
-> Maybe Package -> Package -> MetaDoc mod (Wrap NsRdrName)
parseParas ParserOpts
parserOpts Maybe Package
pkg ([HsDocString] -> Package
renderHsDocStrings ([HsDocString] -> Package) -> [HsDocString] -> Package
forall a b. (a -> b) -> a -> b
$ WithHsDocIdentifiers [HsDocString] GhcRn -> [HsDocString]
forall a pass. WithHsDocIdentifiers a pass -> a
hsDocString WithHsDocIdentifiers [HsDocString] GhcRn
hds)
where
hds :: WithHsDocIdentifiers [HsDocString] GhcRn
hds :: WithHsDocIdentifiers [HsDocString] GhcRn
hds = [HsDocString]
-> [Located (IdP GhcRn)]
-> WithHsDocIdentifiers [HsDocString] GhcRn
forall a pass.
a -> [Located (IdP pass)] -> WithHsDocIdentifiers a pass
WithHsDocIdentifiers ((HsDoc GhcRn -> HsDocString) -> [HsDoc GhcRn] -> [HsDocString]
forall a b. (a -> b) -> [a] -> [b]
map HsDoc GhcRn -> HsDocString
forall a pass. WithHsDocIdentifiers a pass -> a
hsDocString [HsDoc GhcRn]
hdss) ((HsDoc GhcRn -> [Located Name]) -> [HsDoc GhcRn] -> [Located Name]
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> [b]) -> t a -> [b]
concatMap HsDoc GhcRn -> [Located (IdP GhcRn)]
HsDoc GhcRn -> [Located Name]
forall a pass. WithHsDocIdentifiers a pass -> [Located (IdP pass)]
hsDocIdentifiers [HsDoc GhcRn]
hdss)
processDocStringParas
:: MonadIO m
=> ParserOpts
-> SDocContext
-> Maybe Package
-> HsDoc GhcRn
-> IfM m (MDoc Name)
processDocStringParas :: forall (m :: Type -> Type).
MonadIO m =>
ParserOpts
-> SDocContext -> Maybe Package -> HsDoc GhcRn -> IfM m (MDoc Name)
processDocStringParas ParserOpts
parserOpts SDocContext
sDocContext Maybe Package
pkg HsDoc GhcRn
hds =
(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name)
forall (f :: Type -> Type) a b c d.
Functor f =>
(DocH a b -> f (DocH c d)) -> MetaDoc a b -> f (MetaDoc c d)
overDocF (SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename SDocContext
sDocContext (Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. (a -> b) -> a -> b
$ HsDoc GhcRn -> Renamer
forall a. WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer HsDoc GhcRn
hds) (MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (MDoc Name)
forall a b. (a -> b) -> a -> b
$ ParserOpts
-> Maybe Package
-> Package
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
forall mod.
ParserOpts
-> Maybe Package -> Package -> MetaDoc mod (Wrap NsRdrName)
parseParas ParserOpts
parserOpts Maybe Package
pkg (HsDocString -> Package
renderHsDocString (HsDocString -> Package) -> HsDocString -> Package
forall a b. (a -> b) -> a -> b
$ HsDoc GhcRn -> HsDocString
forall a pass. WithHsDocIdentifiers a pass -> a
hsDocString HsDoc GhcRn
hds)
processDocString
:: MonadIO m
=> ParserOpts
-> SDocContext
-> HsDoc GhcRn
-> IfM m (Doc Name)
processDocString :: forall (m :: Type -> Type).
MonadIO m =>
ParserOpts
-> SDocContext
-> HsDoc GhcRn
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
processDocString ParserOpts
parserOpts SDocContext
sDocContext HsDoc GhcRn
hds =
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename SDocContext
sDocContext (HsDoc GhcRn -> Renamer
forall a. WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer HsDoc GhcRn
hds) (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. (a -> b) -> a -> b
$ ParserOpts
-> Package -> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
forall mod. ParserOpts -> Package -> DocH mod (Wrap NsRdrName)
parseString ParserOpts
parserOpts (HsDocString -> Package
renderHsDocString (HsDocString -> Package) -> HsDocString -> Package
forall a b. (a -> b) -> a -> b
$ HsDoc GhcRn -> HsDocString
forall a pass. WithHsDocIdentifiers a pass -> a
hsDocString HsDoc GhcRn
hds)
processModuleHeader
:: MonadIO m
=> Maybe Language
-> ParserOpts
-> SDocContext
-> Maybe Package
-> SafeHaskellMode
-> Maybe Language
-> EnumSet LangExt.Extension
-> Maybe (HsDoc GhcRn)
-> IfM m (HaddockModInfo Name, Maybe (MDoc Name))
Maybe Language
mLanguage ParserOpts
parserOpts SDocContext
sDocContext Maybe Package
pkgName SafeHaskellMode
safety Maybe Language
mayLang EnumSet Extension
extSet Maybe (HsDoc GhcRn)
mayStr = do
(hmi, doc) <-
case Maybe (HsDoc GhcRn)
mayStr of
Maybe (HsDoc GhcRn)
Nothing -> (HaddockModInfo Name, Maybe (MDoc Name))
-> IfM m (HaddockModInfo Name, Maybe (MDoc Name))
forall a. a -> IfM m a
forall (m :: Type -> Type) a. Monad m => a -> m a
return (HaddockModInfo Name, Maybe (MDoc Name))
forall {a} {a}. (HaddockModInfo a, Maybe a)
failure
Just HsDoc GhcRn
hsDoc -> do
let str :: Package
str = HsDocString -> Package
renderHsDocString (HsDocString -> Package) -> HsDocString -> Package
forall a b. (a -> b) -> a -> b
$ HsDoc GhcRn -> HsDocString
forall a pass. WithHsDocIdentifiers a pass -> a
hsDocString HsDoc GhcRn
hsDoc
(HaddockModInfo NsRdrName
hmi, MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc) = ParserOpts
-> Maybe Package
-> Package
-> (HaddockModInfo NsRdrName,
MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
parseModuleHeader ParserOpts
parserOpts Maybe Package
pkgName Package
str
renamer :: Renamer
renamer = HsDoc GhcRn -> Renamer
forall a. WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer HsDoc GhcRn
hsDoc
!descr <- case HaddockModInfo NsRdrName
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
forall name. HaddockModInfo name -> Maybe (Doc name)
hmi_description HaddockModInfo NsRdrName
hmi of
Just DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
hmi_descr -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> Maybe a
Just (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename SDocContext
sDocContext Renamer
renamer DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
hmi_descr
Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
Nothing -> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. Maybe a
Nothing
let hmi' = HaddockModInfo NsRdrName
hmi{hmi_description = descr}
doc' <- overDocF (rename sDocContext renamer) doc
return (hmi', Just doc')
let flags :: [LangExt.Extension]
flags = EnumSet Extension -> [Extension]
forall a. Enum a => EnumSet a -> [a]
EnumSet.toList EnumSet Extension
extSet [Extension] -> [Extension] -> [Extension]
forall a. Eq a => [a] -> [a] -> [a]
\\ Maybe Language -> [Extension]
languageExtensions Maybe Language
mayLang
return
( hmi
{ hmi_safety = Just $ Outputable.renderWithContext sDocContext (Outputable.ppr safety)
, hmi_language = mLanguage
, hmi_extensions = flags
}
, doc
)
where
failure :: (HaddockModInfo a, Maybe a)
failure = (HaddockModInfo a
forall a. HaddockModInfo a
emptyHaddockModInfo, Maybe a
forall a. Maybe a
Nothing)
traverseSnd :: (Traversable t, Applicative f) => (a -> f b) -> t (x, a) -> f (t (x, b))
traverseSnd :: forall (t :: Type -> Type) (f :: Type -> Type) a b x.
(Traversable t, Applicative f) =>
(a -> f b) -> t (x, a) -> f (t (x, b))
traverseSnd a -> f b
f =
((x, a) -> f (x, b)) -> t (x, a) -> f (t (x, b))
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b)
traverse
( \(x
x, a
a) ->
(\b
b -> (x
x, b
b)) (b -> (x, b)) -> f b -> f (x, b)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
)
rename
:: MonadIO m
=> SDocContext
-> Renamer
-> Doc NsRdrName
-> IfM m (Doc Name)
rename :: forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Renamer
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename SDocContext
sDocContext Renamer
renamer = DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn
where
rn :: MonadIO m => Doc NsRdrName -> IfM m (Doc Name)
rn :: forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
d = case DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
d of
DocAppend DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
b -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id -> DocH mod id
DocAppend (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. IfM m (a -> b) -> IfM m a -> IfM m b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
b
DocParagraph DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
p -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocParagraph (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
p
DocIdentifier Wrap NsRdrName
i -> do
let NsRdrName Namespace
ns RdrName
x = Wrap NsRdrName -> NsRdrName
forall n. Wrap n -> n
unwrap Wrap NsRdrName
i
occ :: OccName
occ = RdrName -> OccName
rdrNameOcc RdrName
x
let valueNsChoices :: NameSpace -> Bool
valueNsChoices
| OccName -> Bool
isDataOcc OccName
occ = NameSpace -> Bool
isDataConNameSpace
| Bool
otherwise = NameSpace -> Bool
isTermVarOrFieldNameSpace
typeNsChoices :: NameSpace -> Bool
typeNsChoices
| OccName -> Bool
isDataOcc OccName
occ = NameSpace -> Bool
isTcClsNameSpace
| Bool
otherwise = NameSpace -> Bool
isTvNameSpace
let choices :: NameSpace -> Bool
choices = case Namespace
ns of
Namespace
Value -> NameSpace -> Bool
valueNsChoices
Namespace
Type -> NameSpace -> Bool
typeNsChoices
Namespace
None -> NameSpace -> Bool
valueNsChoices (NameSpace -> Bool) -> (NameSpace -> Bool) -> NameSpace -> Bool
forall (f :: Type -> Type).
Applicative f =>
f Bool -> f Bool -> f Bool
<||> NameSpace -> Bool
typeNsChoices
case Renamer
renamer (SDocContext -> SDoc -> Package
Outputable.renderWithContext SDocContext
sDocContext (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
Outputable.ppr RdrName
x)) NameSpace -> Bool
choices of
[] -> case Namespace
ns of
Namespace
Type -> SDocContext
-> Namespace
-> Wrap RdrName
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type) a.
MonadIO m =>
SDocContext -> Namespace -> Wrap RdrName -> IfM m (Doc a)
outOfScope SDocContext
sDocContext Namespace
ns (Wrap NsRdrName
i Wrap NsRdrName -> RdrName -> Wrap RdrName
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> RdrName -> NameSpace -> RdrName
setRdrNameSpace RdrName
x NameSpace
tcName)
Namespace
_ -> SDocContext
-> Namespace
-> Wrap RdrName
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type) a.
MonadIO m =>
SDocContext -> Namespace -> Wrap RdrName -> IfM m (Doc a)
outOfScope SDocContext
sDocContext Namespace
ns (Wrap NsRdrName
i Wrap NsRdrName -> RdrName -> Wrap RdrName
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> RdrName
x)
[Name
a] -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Wrap Name -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. id -> DocH mod id
DocIdentifier (Wrap Name -> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> Wrap Name -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall a b. (a -> b) -> a -> b
$ Wrap NsRdrName
i Wrap NsRdrName -> Name -> Wrap Name
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> Name
a)
[Name]
names -> SDocContext
-> Wrap NsRdrName
-> [Name]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Wrap NsRdrName
-> [Name]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
ambiguous SDocContext
sDocContext Wrap NsRdrName
i [Name]
names
DocWarning DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dw -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocWarning (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dw
DocEmphasis DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
de -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocEmphasis (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
de
DocBold DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
db -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocBold (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
db
DocMonospaced DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dm -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocMonospaced (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dm
DocUnorderedList [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
docs -> [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. [DocH mod id] -> DocH mod id
DocUnorderedList ([DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
-> IfM m [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
docs
DocOrderedList [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
docs -> [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. [(Int, DocH mod id)] -> DocH mod id
DocOrderedList ([(Int, DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
-> IfM m [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
forall (t :: Type -> Type) (f :: Type -> Type) a b x.
(Traversable t, Applicative f) =>
(a -> f b) -> t (x, a) -> f (t (x, b))
traverseSnd DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn [(Int, DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
docs
DocDefList [(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
list -> [(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. [(DocH mod id, DocH mod id)] -> DocH mod id
DocDefList ([(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM
m
[(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ((DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
-> IfM
m
[(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (\(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a, DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
b) -> (,) (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM
m
(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. IfM m (a -> b) -> IfM m a -> IfM m b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
b) [(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
list
DocCodeBlock DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dcb -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id -> DocH mod id
DocCodeBlock (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
dcb
DocIdentifierUnchecked Wrap (ModuleName, OccName)
x -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Wrap (ModuleName, OccName)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. mod -> DocH mod id
DocIdentifierUnchecked Wrap (ModuleName, OccName)
x)
DocModule (ModLink Package
m Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
l) -> ModLink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. ModLink (DocH mod id) -> DocH mod id
DocModule (ModLink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ModLink (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Package
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ModLink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall id. Package -> Maybe id -> ModLink id
ModLink Package
m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
l
DocHyperlink (Hyperlink Package
u Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
l) -> Hyperlink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Hyperlink (DocH mod id) -> DocH mod id
DocHyperlink (Hyperlink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> Hyperlink (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Package
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> Hyperlink (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall id. Package -> Maybe id -> Hyperlink id
Hyperlink Package
u (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> IfM m (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
l
DocPic Picture
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Picture -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Picture -> DocH mod id
DocPic Picture
str)
DocMathInline Package
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Package -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Package -> DocH mod id
DocMathInline Package
str)
DocMathDisplay Package
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Package -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Package -> DocH mod id
DocMathDisplay Package
str)
DocAName Package
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Package -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Package -> DocH mod id
DocAName Package
str)
DocProperty Package
p -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Package -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Package -> DocH mod id
DocProperty Package
p)
DocExamples [Example]
e -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure ([Example] -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. [Example] -> DocH mod id
DocExamples [Example]
e)
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
DocEmpty -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. DocH mod id
DocEmpty)
DocString Package
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Package -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Package -> DocH mod id
DocString Package
str)
DocHeader (Header Int
l DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
t) -> Header (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Header (DocH mod id) -> DocH mod id
DocHeader (Header (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> Header (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> Header (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall id. Int -> id -> Header id
Header Int
l (DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
t
DocTable Table (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
t -> Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. Table (DocH mod id) -> DocH mod id
DocTable (Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> IfM m (Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Table (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> IfM m (Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: Type -> Type) (f :: Type -> Type) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: Type -> Type) a b.
Applicative f =>
(a -> f b) -> Table a -> f (Table b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (m :: Type -> Type).
MonadIO m =>
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn Table (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
t
outOfScope :: MonadIO m => SDocContext -> Namespace -> Wrap RdrName -> IfM m (Doc a)
outOfScope :: forall (m :: Type -> Type) a.
MonadIO m =>
SDocContext -> Namespace -> Wrap RdrName -> IfM m (Doc a)
outOfScope SDocContext
sDocContext Namespace
ns Wrap RdrName
x =
case Wrap RdrName -> RdrName
forall n. Wrap n -> n
unwrap Wrap RdrName
x of
Unqual OccName
occ -> Wrap OccName -> IfM m (Doc a)
forall (m :: Type -> Type) a mod id.
(MonadIO m, Outputable a) =>
Wrap a -> IfM m (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> OccName -> Wrap OccName
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> OccName
occ)
Qual ModuleName
mdl OccName
occ -> Doc a -> IfM m (Doc a)
forall a. a -> IfM m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Wrap (ModuleName, OccName) -> Doc a
forall mod id. mod -> DocH mod id
DocIdentifierUnchecked (Wrap RdrName
x Wrap RdrName -> (ModuleName, OccName) -> Wrap (ModuleName, OccName)
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> (ModuleName
mdl, OccName
occ)))
Orig Module
_ OccName
occ -> Wrap OccName -> IfM m (Doc a)
forall (m :: Type -> Type) a mod id.
(MonadIO m, Outputable a) =>
Wrap a -> IfM m (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> OccName -> Wrap OccName
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> OccName
occ)
Exact Name
name -> Wrap Name -> IfM m (Doc a)
forall (m :: Type -> Type) a mod id.
(MonadIO m, Outputable a) =>
Wrap a -> IfM m (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> Name -> Wrap Name
forall (f :: Type -> Type) a b. Functor f => f a -> b -> f b
$> Name
name)
where
prefix :: Package
prefix =
case Namespace
ns of
Namespace
Value -> Package
"the value "
Namespace
Type -> Package
"the type "
Namespace
None -> Package
""
warnAndMonospace :: (MonadIO m, Outputable a) => Wrap a -> IfM m (DocH mod id)
warnAndMonospace :: forall (m :: Type -> Type) a mod id.
(MonadIO m, Outputable a) =>
Wrap a -> IfM m (DocH mod id)
warnAndMonospace Wrap a
a = do
let a' :: Package
a' = (a -> Package) -> Wrap a -> Package
forall a. (a -> Package) -> Wrap a -> Package
showWrapped (SDocContext -> SDoc -> Package
renderWithContext SDocContext
sDocContext (SDoc -> Package) -> (a -> SDoc) -> a -> Package
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> SDoc
forall a. Outputable a => a -> SDoc
Outputable.ppr) Wrap a
a
firstWarn <- Package -> Set Package -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.notMember Package
a' (Set Package -> Bool) -> IfM m (Set Package) -> IfM m Bool
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (IfEnv m -> Set Package) -> IfM m (Set Package)
forall s (m :: Type -> Type) a. MonadState s m => (s -> a) -> m a
gets IfEnv m -> Set Package
forall (m :: Type -> Type). IfEnv m -> Set Package
ifeOutOfScopeNames
when firstWarn $ do
warn $
"Warning: "
++ prefix
++ "'"
++ a'
++ "' is out of scope.\n"
++ " If you qualify the identifier, haddock can try to link it anyway."
modify' (\IfEnv m
env -> IfEnv m
env{ifeOutOfScopeNames = Set.insert a' (ifeOutOfScopeNames env)})
pure (monospaced a')
monospaced :: Package -> DocH mod id
monospaced = DocH mod id -> DocH mod id
forall mod id. DocH mod id -> DocH mod id
DocMonospaced (DocH mod id -> DocH mod id)
-> (Package -> DocH mod id) -> Package -> DocH mod id
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Package -> DocH mod id
forall mod id. Package -> DocH mod id
DocString
ambiguous
:: MonadIO m
=> SDocContext
-> Wrap NsRdrName
-> [Name]
-> IfM m (Doc Name)
ambiguous :: forall (m :: Type -> Type).
MonadIO m =>
SDocContext
-> Wrap NsRdrName
-> [Name]
-> IfM m (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
ambiguous SDocContext
sDocContext Wrap NsRdrName
x [Name]
names = do
let noChildren :: [Name]
noChildren = (AvailInfo -> Name) -> [AvailInfo] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map AvailInfo -> Name
availName ([AvailInfo] -> [AvailInfo]
nubAvails ((Name -> AvailInfo) -> [Name] -> [AvailInfo]
forall a b. (a -> b) -> [a] -> [b]
map Name -> AvailInfo
Avail [Name]
names))
dflt :: Name
dflt = (Name -> Name -> Ordering) -> [Name] -> Name
forall (t :: Type -> Type) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
maximumBy ((Name -> (Bool, Bool)) -> Name -> Name -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing (Name -> Bool
isLocalName (Name -> Bool) -> (Name -> Bool) -> Name -> (Bool, Bool)
forall b c c'. (b -> c) -> (b -> c') -> b -> (c, c')
forall (a :: Type -> Type -> Type) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& Name -> Bool
isTyConName)) [Name]
noChildren
nameStr :: Package
nameStr = SDocContext -> Wrap NsRdrName -> Package
showNsRdrName SDocContext
sDocContext Wrap NsRdrName
x
msg :: Package
msg =
Package
"Warning: "
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
nameStr
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" is ambiguous. It is defined\n"
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ (Name -> Package) -> [Name] -> Package
forall (t :: Type -> Type) a b.
Foldable t =>
(a -> [b]) -> t a -> [b]
concatMap (\Name
n -> Package
" * " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Name -> Package
defnLoc Name
n Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"\n") [Name]
names
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" You may be able to disambiguate the identifier by qualifying it or\n"
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" by specifying the type/value namespace explicitly.\n"
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" Defaulting to the one defined "
Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Name -> Package
defnLoc Name
dflt
firstWarn <- Package -> Set Package -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.notMember Package
nameStr (Set Package -> Bool) -> IfM m (Set Package) -> IfM m Bool
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (IfEnv m -> Set Package) -> IfM m (Set Package)
forall s (m :: Type -> Type) a. MonadState s m => (s -> a) -> m a
gets IfEnv m -> Set Package
forall (m :: Type -> Type). IfEnv m -> Set Package
ifeAmbiguousNames
when (length noChildren > 1 && firstWarn) $ do
warn msg
modify' (\IfEnv m
env -> IfEnv m
env{ifeAmbiguousNames = Set.insert nameStr (ifeAmbiguousNames env)})
pure (DocIdentifier (x $> dflt))
where
isLocalName :: Name -> Bool
isLocalName (Name -> SrcLoc
nameSrcLoc -> RealSrcLoc{}) = Bool
True
isLocalName Name
_ = Bool
False
defnLoc :: Name -> Package
defnLoc = SDocContext -> SDoc -> Package
Outputable.renderWithContext SDocContext
sDocContext (SDoc -> Package) -> (Name -> SDoc) -> Name -> Package
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> SDoc
pprNameDefnLoc
showNsRdrName :: SDocContext -> Wrap NsRdrName -> String
showNsRdrName :: SDocContext -> Wrap NsRdrName -> Package
showNsRdrName SDocContext
sDocContext = (\Package
p Package
i -> Package
p Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"'" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
i Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"'") (Package -> Package -> Package)
-> (Wrap NsRdrName -> Package)
-> Wrap NsRdrName
-> Package
-> Package
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Wrap NsRdrName -> Package
prefix (Wrap NsRdrName -> Package -> Package)
-> (Wrap NsRdrName -> Package) -> Wrap NsRdrName -> Package
forall a b.
(Wrap NsRdrName -> a -> b)
-> (Wrap NsRdrName -> a) -> Wrap NsRdrName -> b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Wrap NsRdrName -> Package
ident
where
ident :: Wrap NsRdrName -> Package
ident = (NsRdrName -> Package) -> Wrap NsRdrName -> Package
forall a. (a -> Package) -> Wrap a -> Package
showWrapped (SDocContext -> SDoc -> Package
Outputable.renderWithContext SDocContext
sDocContext (SDoc -> Package) -> (NsRdrName -> SDoc) -> NsRdrName -> Package
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr (RdrName -> SDoc) -> (NsRdrName -> RdrName) -> NsRdrName -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NsRdrName -> RdrName
rdrName)
prefix :: Wrap NsRdrName -> Package
prefix = Namespace -> Package
renderNs (Namespace -> Package)
-> (Wrap NsRdrName -> Namespace) -> Wrap NsRdrName -> Package
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NsRdrName -> Namespace
namespace (NsRdrName -> Namespace)
-> (Wrap NsRdrName -> NsRdrName) -> Wrap NsRdrName -> Namespace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Wrap NsRdrName -> NsRdrName
forall n. Wrap n -> n
unwrap
hsDocRenamer :: WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer :: forall a. WithHsDocIdentifiers a GhcRn -> Renamer
hsDocRenamer WithHsDocIdentifiers a GhcRn
hsDoc = \Package
s NameSpace -> Bool
cands -> NameSet -> [Name]
nameSetElemsStable (NameSet -> [Name]) -> NameSet -> [Name]
forall a b. (a -> b) -> a -> b
$ (Name -> Bool) -> NameSet -> NameSet
filterNameSet (Package -> (NameSpace -> Bool) -> Name -> Bool
forall {p}.
HasOccName p =>
Package -> (NameSpace -> Bool) -> p -> Bool
nameMatches Package
s NameSpace -> Bool
cands) NameSet
env
where
!env :: NameSet
env = WithHsDocIdentifiers a GhcRn -> NameSet
forall a. WithHsDocIdentifiers a GhcRn -> NameSet
hsDocIds WithHsDocIdentifiers a GhcRn
hsDoc
nameMatches :: Package -> (NameSpace -> Bool) -> p -> Bool
nameMatches Package
s NameSpace -> Bool
ok_ns p
n =
let occ :: OccName
occ = p -> OccName
forall name. HasOccName name => name -> OccName
occName p
n
in NameSpace -> Bool
ok_ns (OccName -> NameSpace
occNameSpace OccName
occ) Bool -> Bool -> Bool
&& Package
s Package -> Package -> Bool
forall a. Eq a => a -> a -> Bool
== FastString -> Package
unpackFS (OccName -> FastString
occNameFS OccName
occ)