module GHC.Rename.Doc ( rnHsDoc, rnLHsDoc, rnLDocDecl, rnDocDecl ) where import GHC.Prelude import GHC.Tc.Types import GHC.Hs import GHC.Types.Name.Reader import GHC.Types.Name import GHC.Types.SrcLoc import GHC.Tc.Utils.Monad (getGblEnv) rnLHsDoc :: LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc :: LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc = (HsDoc GhcPs -> IOEnv (Env TcGblEnv TcLclEnv) (HsDoc GhcRn)) -> LHsDoc GhcPs -> RnM (LHsDoc GhcRn) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> GenLocated SrcSpan a -> f (GenLocated SrcSpan b) traverse HsDoc GhcPs -> IOEnv (Env TcGblEnv TcLclEnv) (HsDoc GhcRn) forall a. WithHsDocIdentifiers a GhcPs -> RnM (WithHsDocIdentifiers a GhcRn) rnHsDoc rnLDocDecl :: LDocDecl GhcPs -> RnM (LDocDecl GhcRn) rnLDocDecl :: LDocDecl GhcPs -> RnM (LDocDecl GhcRn) rnLDocDecl = (DocDecl GhcPs -> IOEnv (Env TcGblEnv TcLclEnv) (DocDecl GhcRn)) -> GenLocated SrcSpanAnnA (DocDecl GhcPs) -> IOEnv (Env TcGblEnv TcLclEnv) (GenLocated SrcSpanAnnA (DocDecl GhcRn)) forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> GenLocated SrcSpanAnnA a -> f (GenLocated SrcSpanAnnA b) traverse DocDecl GhcPs -> IOEnv (Env TcGblEnv TcLclEnv) (DocDecl GhcRn) rnDocDecl rnDocDecl :: DocDecl GhcPs -> RnM (DocDecl GhcRn) rnDocDecl :: DocDecl GhcPs -> IOEnv (Env TcGblEnv TcLclEnv) (DocDecl GhcRn) rnDocDecl (DocCommentNext LHsDoc GhcPs doc) = do doc' <- LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc LHsDoc GhcPs doc pure $ (DocCommentNext doc') rnDocDecl (DocCommentPrev LHsDoc GhcPs doc) = do doc' <- LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc LHsDoc GhcPs doc pure $ (DocCommentPrev doc') rnDocDecl (DocCommentNamed String n LHsDoc GhcPs doc) = do doc' <- LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc LHsDoc GhcPs doc pure $ (DocCommentNamed n doc') rnDocDecl (DocGroup Int i LHsDoc GhcPs doc) = do doc' <- LHsDoc GhcPs -> RnM (LHsDoc GhcRn) rnLHsDoc LHsDoc GhcPs doc pure $ (DocGroup i doc') rnHsDoc :: WithHsDocIdentifiers a GhcPs -> RnM (WithHsDocIdentifiers a GhcRn) rnHsDoc :: forall a. WithHsDocIdentifiers a GhcPs -> RnM (WithHsDocIdentifiers a GhcRn) rnHsDoc (WithHsDocIdentifiers a s [Located (IdP GhcPs)] ids) = do gre <- TcGblEnv -> GlobalRdrEnv tcg_rdr_env (TcGblEnv -> GlobalRdrEnv) -> IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv -> IOEnv (Env TcGblEnv TcLclEnv) GlobalRdrEnv forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv forall gbl lcl. TcRnIf gbl lcl gbl getGblEnv pure (WithHsDocIdentifiers s (rnHsDocIdentifiers gre ids)) rnHsDocIdentifiers :: GlobalRdrEnv -> [Located RdrName] -> [Located Name] rnHsDocIdentifiers :: GlobalRdrEnv -> [Located RdrName] -> [Located Name] rnHsDocIdentifiers GlobalRdrEnv gre_env [Located RdrName] ns = [ SrcSpan -> Name -> Located Name forall l e. l -> e -> GenLocated l e L SrcSpan l (Name -> Located Name) -> Name -> Located Name forall a b. (a -> b) -> a -> b $ GlobalRdrEltX GREInfo -> Name forall info. GlobalRdrEltX info -> Name greName GlobalRdrEltX GREInfo gre | L SrcSpan l RdrName rdr_name <- [Located RdrName] ns , GlobalRdrEltX GREInfo gre <- GlobalRdrEnv -> LookupGRE GREInfo -> [GlobalRdrEltX GREInfo] forall info. GlobalRdrEnvX info -> LookupGRE info -> [GlobalRdrEltX info] lookupGRE GlobalRdrEnv gre_env (RdrName -> WhichGREs GREInfo -> LookupGRE GREInfo forall info. RdrName -> WhichGREs info -> LookupGRE info LookupRdrName RdrName rdr_name WhichGREs GREInfo AllRelevantGREs) ]