{-# OPTIONS_GHC -Wwarn #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
module Haddock.Interface.LexParseRn
( processDocString
, processDocStringParas
, processDocStrings
, processModuleHeader
) where
import Control.Arrow
import Control.Monad
import Data.Functor (($>))
import Data.List (maximumBy, (\\))
import Data.Ord
import Documentation.Haddock.Doc (metaDocConcat)
import DynFlags (languageExtensions)
import qualified GHC.LanguageExtensions as LangExt
import GHC
import Haddock.Interface.ParseModuleHeader
import Haddock.Parser
import Haddock.Types
import Name
import Outputable ( showPpr, showSDoc )
import RdrName
import RdrHsSyn (setRdrNameSpace)
import EnumSet
processDocStrings :: DynFlags -> Maybe Package -> GlobalRdrEnv -> [HsDocString]
-> ErrMsgM (Maybe (MDoc Name))
processDocStrings :: DynFlags
-> Maybe Package
-> GlobalRdrEnv
-> [HsDocString]
-> ErrMsgM (Maybe (MDoc Name))
processDocStrings DynFlags
dflags Maybe Package
pkg GlobalRdrEnv
gre [HsDocString]
strs = do
MDoc Name
mdoc <- [MDoc Name] -> MDoc Name
forall mod id. [MetaDoc mod id] -> MetaDoc mod id
metaDocConcat ([MDoc Name] -> MDoc Name)
-> ErrMsgM [MDoc Name] -> ErrMsgM (MDoc Name)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HsDocString -> ErrMsgM (MDoc Name))
-> [HsDocString] -> ErrMsgM [MDoc Name]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (DynFlags
-> Maybe Package
-> GlobalRdrEnv
-> HsDocString
-> ErrMsgM (MDoc Name)
processDocStringParas DynFlags
dflags Maybe Package
pkg GlobalRdrEnv
gre) [HsDocString]
strs
case MDoc Name
mdoc of
MetaDoc { _meta :: forall mod id. MetaDoc mod id -> Meta
_meta = Meta Maybe Version
Nothing Maybe Package
Nothing, _doc :: forall mod id. MetaDoc mod id -> DocH mod id
_doc = DocH (Wrap (ModuleName, OccName)) (Wrap Name)
DocEmpty } -> Maybe (MDoc Name) -> ErrMsgM (Maybe (MDoc Name))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (MDoc Name)
forall a. Maybe a
Nothing
MDoc Name
x -> Maybe (MDoc Name) -> ErrMsgM (Maybe (MDoc Name))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MDoc Name -> Maybe (MDoc Name)
forall a. a -> Maybe a
Just MDoc Name
x)
processDocStringParas :: DynFlags -> Maybe Package -> GlobalRdrEnv -> HsDocString -> ErrMsgM (MDoc Name)
processDocStringParas :: DynFlags
-> Maybe Package
-> GlobalRdrEnv
-> HsDocString
-> ErrMsgM (MDoc Name)
processDocStringParas DynFlags
dflags Maybe Package
pkg GlobalRdrEnv
gre HsDocString
hds =
(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (MDoc Name)
forall (f :: * -> *) a b c d.
Functor f =>
(DocH a b -> f (DocH c d)) -> MetaDoc a b -> f (MetaDoc c d)
overDocF (DynFlags
-> GlobalRdrEnv
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename DynFlags
dflags GlobalRdrEnv
gre) (MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (MDoc Name))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (MDoc Name)
forall a b. (a -> b) -> a -> b
$ DynFlags
-> Maybe Package
-> Package
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
forall mod.
DynFlags
-> Maybe Package -> Package -> MetaDoc mod (Wrap NsRdrName)
parseParas DynFlags
dflags Maybe Package
pkg (HsDocString -> Package
unpackHDS HsDocString
hds)
processDocString :: DynFlags -> GlobalRdrEnv -> HsDocString -> ErrMsgM (Doc Name)
processDocString :: DynFlags
-> GlobalRdrEnv
-> HsDocString
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
processDocString DynFlags
dflags GlobalRdrEnv
gre HsDocString
hds =
DynFlags
-> GlobalRdrEnv
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename DynFlags
dflags GlobalRdrEnv
gre (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a b. (a -> b) -> a -> b
$ DynFlags
-> Package -> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
forall mod. DynFlags -> Package -> DocH mod (Wrap NsRdrName)
parseString DynFlags
dflags (HsDocString -> Package
unpackHDS HsDocString
hds)
processModuleHeader :: DynFlags -> Maybe Package -> GlobalRdrEnv -> SafeHaskellMode -> Maybe LHsDocString
-> ErrMsgM (HaddockModInfo Name, Maybe (MDoc Name))
DynFlags
dflags Maybe Package
pkgName GlobalRdrEnv
gre SafeHaskellMode
safety Maybe LHsDocString
mayStr = do
(HaddockModInfo Name
hmi, Maybe (MDoc Name)
doc) <-
case Maybe LHsDocString
mayStr of
Maybe LHsDocString
Nothing -> (HaddockModInfo Name, Maybe (MDoc Name))
-> ErrMsgM (HaddockModInfo Name, Maybe (MDoc Name))
forall (m :: * -> *) a. Monad m => a -> m a
return (HaddockModInfo Name, Maybe (MDoc Name))
forall a a. (HaddockModInfo a, Maybe a)
failure
Just (L SrcSpan
_ HsDocString
hds) -> do
let str :: Package
str = HsDocString -> Package
unpackHDS HsDocString
hds
(HaddockModInfo NsRdrName
hmi, MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc) = DynFlags
-> Maybe Package
-> Package
-> (HaddockModInfo NsRdrName,
MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
parseModuleHeader DynFlags
dflags Maybe Package
pkgName Package
str
!Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
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)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DynFlags
-> GlobalRdrEnv
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename DynFlags
dflags GlobalRdrEnv
gre DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
hmi_descr
Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
Nothing -> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. Maybe a
Nothing
let hmi' :: HaddockModInfo Name
hmi' = HaddockModInfo NsRdrName
hmi { hmi_description :: Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
hmi_description = Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
descr }
MDoc Name
doc' <- (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (MDoc Name)
forall (f :: * -> *) a b c d.
Functor f =>
(DocH a b -> f (DocH c d)) -> MetaDoc a b -> f (MetaDoc c d)
overDocF (DynFlags
-> GlobalRdrEnv
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename DynFlags
dflags GlobalRdrEnv
gre) MetaDoc (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
(HaddockModInfo Name, Maybe (MDoc Name))
-> ErrMsgM (HaddockModInfo Name, Maybe (MDoc Name))
forall (m :: * -> *) a. Monad m => a -> m a
return (HaddockModInfo Name
hmi', MDoc Name -> Maybe (MDoc Name)
forall a. a -> Maybe a
Just MDoc Name
doc')
let flags :: [LangExt.Extension]
flags :: [Extension]
flags = EnumSet Extension -> [Extension]
forall a. Enum a => EnumSet a -> [a]
EnumSet.toList (DynFlags -> EnumSet Extension
extensionFlags DynFlags
dflags) [Extension] -> [Extension] -> [Extension]
forall a. Eq a => [a] -> [a] -> [a]
\\ Maybe Language -> [Extension]
languageExtensions (DynFlags -> Maybe Language
language DynFlags
dflags)
(HaddockModInfo Name, Maybe (MDoc Name))
-> ErrMsgM (HaddockModInfo Name, Maybe (MDoc Name))
forall (m :: * -> *) a. Monad m => a -> m a
return (HaddockModInfo Name
hmi { hmi_safety :: Maybe Package
hmi_safety = Package -> Maybe Package
forall a. a -> Maybe a
Just (Package -> Maybe Package) -> Package -> Maybe Package
forall a b. (a -> b) -> a -> b
$ DynFlags -> SafeHaskellMode -> Package
forall a. Outputable a => DynFlags -> a -> Package
showPpr DynFlags
dflags SafeHaskellMode
safety
, hmi_language :: Maybe Language
hmi_language = DynFlags -> Maybe Language
language DynFlags
dflags
, hmi_extensions :: [Extension]
hmi_extensions = [Extension]
flags
} , Maybe (MDoc Name)
doc)
where
failure :: (HaddockModInfo a, Maybe a)
failure = (HaddockModInfo a
forall a. HaddockModInfo a
emptyHaddockModInfo, Maybe a
forall a. Maybe a
Nothing)
rename :: DynFlags -> GlobalRdrEnv -> Doc NsRdrName -> ErrMsgM (Doc Name)
rename :: DynFlags
-> GlobalRdrEnv
-> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rename DynFlags
dflags GlobalRdrEnv
gre = DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn
where
rn :: DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
b
DocParagraph DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
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
isValueName :: Bool
isValueName = OccName -> Bool
isDataOcc OccName
occ Bool -> Bool -> Bool
|| OccName -> Bool
isVarOcc OccName
occ
let valueNsChoices :: [RdrName]
valueNsChoices | Bool
isValueName = [RdrName
x]
| Bool
otherwise = []
typeNsChoices :: [RdrName]
typeNsChoices | Bool
isValueName = [RdrName -> NameSpace -> RdrName
setRdrNameSpace RdrName
x NameSpace
tcName]
| Bool
otherwise = [RdrName
x]
let choices :: [RdrName]
choices = case Namespace
ns of
Namespace
Value -> [RdrName]
valueNsChoices
Namespace
Type -> [RdrName]
typeNsChoices
Namespace
None -> [RdrName]
valueNsChoices [RdrName] -> [RdrName] -> [RdrName]
forall a. [a] -> [a] -> [a]
++ [RdrName]
typeNsChoices
case (RdrName -> [GlobalRdrElt]) -> [RdrName] -> [GlobalRdrElt]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\RdrName
c -> RdrName -> GlobalRdrEnv -> [GlobalRdrElt]
lookupGRE_RdrName RdrName
c GlobalRdrEnv
gre) [RdrName]
choices of
[] ->
case [RdrName]
choices of
[] -> DynFlags
-> Wrap NsRdrName
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. DynFlags -> Wrap NsRdrName -> ErrMsgM (Doc a)
invalidValue DynFlags
dflags Wrap NsRdrName
i
RdrName
a:[RdrName]
_ -> DynFlags
-> Namespace
-> Wrap RdrName
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall a. DynFlags -> Namespace -> Wrap RdrName -> ErrMsgM (Doc a)
outOfScope DynFlags
dflags Namespace
ns (Wrap NsRdrName
i Wrap NsRdrName -> RdrName -> Wrap RdrName
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> RdrName
a)
[GlobalRdrElt
a] -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Wrap Name -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. id -> DocH mod id
DocIdentifier (Wrap NsRdrName
i Wrap NsRdrName -> Name -> Wrap Name
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> GlobalRdrElt -> Name
gre_name GlobalRdrElt
a))
[GlobalRdrElt]
gres -> DynFlags
-> Wrap NsRdrName
-> [GlobalRdrElt]
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
ambiguous DynFlags
dflags Wrap NsRdrName
i [GlobalRdrElt]
gres
DocWarning DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
DocEmphasis DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
DocBold DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
DocMonospaced DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
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))
-> ErrMsgM [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
-> ErrMsgM [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
docs
DocOrderedList [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
DocOrderedList ([DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)]
-> ErrMsgM [DocH (Wrap (ModuleName, OccName)) (Wrap Name)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn [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))
-> ErrMsgM
[(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> [(DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName),
DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))]
-> ErrMsgM
[(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t 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)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
a ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> (DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM
(DocH (Wrap (ModuleName, OccName)) (Wrap Name),
DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (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)
doc -> 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
doc
DocIdentifierUnchecked Wrap (ModuleName, OccName)
x -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (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))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> ErrMsgM (Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn Maybe (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
l
DocPic Picture
str -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) 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))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (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))
-> ErrMsgM (Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
-> Table (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
-> ErrMsgM (Table (DocH (Wrap (ModuleName, OccName)) (Wrap Name)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
rn Table (DocH (Wrap (ModuleName, OccName)) (Wrap NsRdrName))
t
outOfScope :: DynFlags -> Namespace -> Wrap RdrName -> ErrMsgM (Doc a)
outOfScope :: DynFlags -> Namespace -> Wrap RdrName -> ErrMsgM (Doc a)
outOfScope DynFlags
dflags Namespace
ns Wrap RdrName
x =
case Wrap RdrName -> RdrName
forall n. Wrap n -> n
unwrap Wrap RdrName
x of
Unqual OccName
occ -> Wrap OccName -> ErrMsgM (Doc a)
forall a mod id. Outputable a => Wrap a -> ErrMsgM (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> OccName -> Wrap OccName
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> OccName
occ)
Qual ModuleName
mdl OccName
occ -> Doc a -> ErrMsgM (Doc a)
forall (f :: * -> *) 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 :: * -> *) a b. Functor f => f a -> b -> f b
$> (ModuleName
mdl, OccName
occ)))
Orig Module
_ OccName
occ -> Wrap OccName -> ErrMsgM (Doc a)
forall a mod id. Outputable a => Wrap a -> ErrMsgM (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> OccName -> Wrap OccName
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> OccName
occ)
Exact Name
name -> Wrap Name -> ErrMsgM (Doc a)
forall a mod id. Outputable a => Wrap a -> ErrMsgM (DocH mod id)
warnAndMonospace (Wrap RdrName
x Wrap RdrName -> Name -> Wrap Name
forall (f :: * -> *) 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 :: Wrap a -> ErrMsgM (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 (DynFlags -> a -> Package
forall a. Outputable a => DynFlags -> a -> Package
showPpr DynFlags
dflags) Wrap a
a
[Package] -> ErrMsgM ()
tell [Package
"Warning: " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
prefix Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"'" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
a' Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"' is out of scope.\n" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++
Package
" If you qualify the identifier, haddock can try to link it anyway."]
DocH mod id -> ErrMsgM (DocH mod id)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Package -> DocH mod id
forall mod id. Package -> DocH mod id
monospaced Package
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 :: DynFlags
-> Wrap NsRdrName
-> [GlobalRdrElt]
-> ErrMsgM (Doc Name)
ambiguous :: DynFlags
-> Wrap NsRdrName
-> [GlobalRdrElt]
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
ambiguous DynFlags
dflags Wrap NsRdrName
x [GlobalRdrElt]
gres = do
let dflt :: GlobalRdrElt
dflt = (GlobalRdrElt -> GlobalRdrElt -> Ordering)
-> [GlobalRdrElt] -> GlobalRdrElt
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
maximumBy ((GlobalRdrElt -> (Bool, Bool))
-> GlobalRdrElt -> GlobalRdrElt -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing (GlobalRdrElt -> Bool
gre_lcl (GlobalRdrElt -> Bool)
-> (GlobalRdrElt -> Bool) -> GlobalRdrElt -> (Bool, Bool)
forall (a :: * -> * -> *) b c c'.
Arrow a =>
a b c -> a b c' -> a b (c, c')
&&& Name -> Bool
isTyConName (Name -> Bool) -> (GlobalRdrElt -> Name) -> GlobalRdrElt -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlobalRdrElt -> Name
gre_name)) [GlobalRdrElt]
gres
msg :: Package
msg = Package
"Warning: " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ DynFlags -> Wrap NsRdrName -> Package
showNsRdrName DynFlags
dflags Wrap NsRdrName
x Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" is ambiguous. It is defined\n" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++
(GlobalRdrElt -> Package) -> [GlobalRdrElt] -> Package
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\GlobalRdrElt
n -> Package
" * " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ GlobalRdrElt -> Package
defnLoc GlobalRdrElt
n Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
"\n") [GlobalRdrElt]
gres 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]
++ GlobalRdrElt -> Package
defnLoc GlobalRdrElt
dflt
Bool -> ErrMsgM () -> ErrMsgM ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([AvailInfo] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([GlobalRdrElt] -> [AvailInfo]
gresToAvailInfo [GlobalRdrElt]
gres) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1) (ErrMsgM () -> ErrMsgM ()) -> ErrMsgM () -> ErrMsgM ()
forall a b. (a -> b) -> a -> b
$ [Package] -> ErrMsgM ()
tell [Package
msg]
DocH (Wrap (ModuleName, OccName)) (Wrap Name)
-> ErrMsgM (DocH (Wrap (ModuleName, OccName)) (Wrap Name))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Wrap Name -> DocH (Wrap (ModuleName, OccName)) (Wrap Name)
forall mod id. id -> DocH mod id
DocIdentifier (Wrap NsRdrName
x Wrap NsRdrName -> Name -> Wrap Name
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> GlobalRdrElt -> Name
gre_name GlobalRdrElt
dflt))
where
defnLoc :: GlobalRdrElt -> Package
defnLoc = DynFlags -> SDoc -> Package
showSDoc DynFlags
dflags (SDoc -> Package)
-> (GlobalRdrElt -> SDoc) -> GlobalRdrElt -> Package
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> SDoc
pprNameDefnLoc (Name -> SDoc) -> (GlobalRdrElt -> Name) -> GlobalRdrElt -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlobalRdrElt -> Name
gre_name
invalidValue :: DynFlags -> Wrap NsRdrName -> ErrMsgM (Doc a)
invalidValue :: DynFlags -> Wrap NsRdrName -> ErrMsgM (Doc a)
invalidValue DynFlags
dflags Wrap NsRdrName
x = do
[Package] -> ErrMsgM ()
tell [Package
"Warning: " Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ DynFlags -> Wrap NsRdrName -> Package
showNsRdrName DynFlags
dflags Wrap NsRdrName
x Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++ Package
" cannot be value, yet it is\n" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++
Package
" namespaced as such. Did you mean to specify a type namespace\n" Package -> Package -> Package
forall a. [a] -> [a] -> [a]
++
Package
" instead?"]
Doc a -> ErrMsgM (Doc a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Doc a -> Doc a
forall mod id. DocH mod id -> DocH mod id
DocMonospaced (Package -> Doc a
forall mod id. Package -> DocH mod id
DocString (DynFlags -> Wrap NsRdrName -> Package
showNsRdrName DynFlags
dflags Wrap NsRdrName
x)))
showNsRdrName :: DynFlags -> Wrap NsRdrName -> String
showNsRdrName :: DynFlags -> Wrap NsRdrName -> Package
showNsRdrName DynFlags
dflags = (\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 :: * -> *) 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 (f :: * -> *) 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 (DynFlags -> RdrName -> Package
forall a. Outputable a => DynFlags -> a -> Package
showPpr DynFlags
dflags (RdrName -> Package)
-> (NsRdrName -> RdrName) -> NsRdrName -> Package
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