{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
----------------------------------------------------------------------------
-- |
-- Module      :  Haddock.Interface.Rename
-- Copyright   :  (c) Simon Marlow 2003-2006,
--                    David Waern  2006-2009
-- License     :  BSD-like
--
-- Maintainer  :  haddock@projects.haskell.org
-- Stability   :  experimental
-- Portability :  portable
-----------------------------------------------------------------------------
module Haddock.Interface.Rename (renameInterface) where


import Data.Traversable (mapM)

import Haddock.GhcUtils
import Haddock.Types

import Bag (emptyBag)
import GHC hiding (NoLink)
import Name
import RdrName (RdrName(Exact))
import TysWiredIn (eqTyCon_RDR)

import Control.Applicative
import Control.Arrow ( first )
import Control.Monad hiding (mapM)
import Data.List (intercalate)
import qualified Data.Map as Map hiding ( Map )
import qualified Data.Set as Set
import Prelude hiding (mapM)

-- | Traverse docstrings and ASTs in the Haddock interface, renaming 'Name' to
-- 'DocName'.
--
-- What this really boils down to is: for each 'Name', figure out which of the
-- modules that export the name is the preferred place to link to.
--
-- The renamed output gets written into fields in the Haddock interface record
-- that were previously left empty.
renameInterface :: DynFlags -> [String] -> LinkEnv -> Bool -> Interface -> ErrMsgM Interface
renameInterface :: DynFlags
-> [String] -> LinkEnv -> Bool -> Interface -> ErrMsgM Interface
renameInterface DynFlags
_dflags [String]
ignoredSymbols LinkEnv
renamingEnv Bool
warnings Interface
iface =

  -- first create the local env, where every name exported by this module
  -- is mapped to itself, and everything else comes from the global renaming
  -- env
  let localEnv :: LinkEnv
localEnv = (LinkEnv -> Name -> LinkEnv) -> LinkEnv -> [Name] -> LinkEnv
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl LinkEnv -> Name -> LinkEnv
fn LinkEnv
renamingEnv (Interface -> [Name]
ifaceVisibleExports Interface
iface)
        where fn :: LinkEnv -> Name -> LinkEnv
fn LinkEnv
env Name
name = Name -> Module -> LinkEnv -> LinkEnv
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Name
name (Interface -> Module
ifaceMod Interface
iface) LinkEnv
env

      -- rename names in the exported declarations to point to things that
      -- are closer to, or maybe even exported by, the current module.
      ([ExportItem DocNameI]
renamedExportItems, [Name]
missingNames1)
        = LinkEnv
-> RnM [ExportItem DocNameI] -> ([ExportItem DocNameI], [Name])
forall a. LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
localEnv ([ExportItem GhcRn] -> RnM [ExportItem DocNameI]
renameExportItems (Interface -> [ExportItem GhcRn]
ifaceExportItems Interface
iface))

      (Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
rnDocMap, [Name]
missingNames2) = LinkEnv
-> RnM
     (Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> (Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
    [Name])
forall a. LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
localEnv ((MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
 -> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc (Interface
-> Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
ifaceDocMap Interface
iface))

      (Map
  Name
  (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
rnArgMap, [Name]
missingNames3) = LinkEnv
-> RnM
     (Map
        Name
        (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))))
-> (Map
      Name
      (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))),
    [Name])
forall a. LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
localEnv ((Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
 -> RnM
      (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))))
-> Map
     Name (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)))
-> RnM
     (Map
        Name
        (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
 -> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc) (Interface
-> Map
     Name (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)))
ifaceArgMap Interface
iface))

      ([(InstHead DocNameI,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
  Located DocName, Maybe Module)]
renamedOrphanInstances, [Name]
missingNames4)
        = LinkEnv
-> RnM
     [(InstHead DocNameI,
       Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
       Located DocName, Maybe Module)]
-> ([(InstHead DocNameI,
      Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
      Located DocName, Maybe Module)],
    [Name])
forall a. LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
localEnv (((InstHead GhcRn,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
  Located Name, Maybe Module)
 -> RnM
      (InstHead DocNameI,
       Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
       Located DocName, Maybe Module))
-> [(InstHead GhcRn,
     Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
     Located Name, Maybe Module)]
-> RnM
     [(InstHead DocNameI,
       Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
       Located DocName, Maybe Module)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DocInstance GhcRn -> RnM (DocInstance DocNameI)
(InstHead GhcRn,
 Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
 Located Name, Maybe Module)
-> RnM
     (InstHead DocNameI,
      Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
      Located DocName, Maybe Module)
renameDocInstance (Interface -> [DocInstance GhcRn]
ifaceOrphanInstances Interface
iface))

      (Documentation DocName
finalModuleDoc, [Name]
missingNames5)
        = LinkEnv
-> RnM (Documentation DocName) -> (Documentation DocName, [Name])
forall a. LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
localEnv (Documentation Name -> RnM (Documentation DocName)
renameDocumentation (Interface -> Documentation Name
ifaceDoc Interface
iface))

      -- combine the missing names and filter out the built-ins, which would
      -- otherwise always be missing.
      missingNames :: [Name]
missingNames = (Name -> Name) -> [Name] -> [Name]
forall a. (a -> Name) -> [a] -> [a]
nubByName Name -> Name
forall a. a -> a
id ([Name] -> [Name]) -> [Name] -> [Name]
forall a b. (a -> b) -> a -> b
$ (Name -> Bool) -> [Name] -> [Name]
forall a. (a -> Bool) -> [a] -> [a]
filter Name -> Bool
isExternalName  -- XXX: isExternalName filters out too much
                    ([Name]
missingNames1 [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [Name]
missingNames2 [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [Name]
missingNames3
                     [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [Name]
missingNames4 [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [Name]
missingNames5)

      -- Filter out certain built in type constructors using their string
      -- representation.
      --
      -- Note that since the renamed AST represents equality constraints as
      -- @HasOpTy t1 eqTyCon_RDR t2@ (and _not_ as @HsEqTy t1 t2@), we need to
      -- manually filter out 'eqTyCon_RDR' (aka @~@).

      qualifiedName :: Name -> String
qualifiedName Name
n = (ModuleName -> String
moduleNameString (ModuleName -> String) -> ModuleName -> String
forall a b. (a -> b) -> a -> b
$ Module -> ModuleName
moduleName (Module -> ModuleName) -> Module -> ModuleName
forall a b. (a -> b) -> a -> b
$ HasDebugCallStack => Name -> Module
Name -> Module
nameModule Name
n) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"." String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall a. NamedThing a => a -> String
getOccString Name
n

      ignoreSet :: Set String
ignoreSet = [String] -> Set String
forall a. Ord a => [a] -> Set a
Set.fromList [String]
ignoredSymbols

      strings :: [String]
strings = [ Name -> String
qualifiedName Name
n

                | Name
n <- [Name]
missingNames
                , Bool -> Bool
not (Name -> String
qualifiedName Name
n String -> Set String -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set String
ignoreSet)
                , Bool -> Bool
not (Name -> Bool
isSystemName Name
n)
                , Bool -> Bool
not (Name -> Bool
isBuiltInSyntax Name
n)
                , Name -> RdrName
Exact Name
n RdrName -> RdrName -> Bool
forall a. Eq a => a -> a -> Bool
/= RdrName
eqTyCon_RDR
                ]

  in do
    -- report things that we couldn't link to. Only do this for non-hidden
    -- modules.
    Bool -> ErrMsgM () -> ErrMsgM ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (DocOption
OptHide DocOption -> [DocOption] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` Interface -> [DocOption]
ifaceOptions Interface
iface Bool -> Bool -> Bool
|| [String] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
strings Bool -> Bool -> Bool
|| Bool -> Bool
not Bool
warnings) (ErrMsgM () -> ErrMsgM ()) -> ErrMsgM () -> ErrMsgM ()
forall a b. (a -> b) -> a -> b
$
      [String] -> ErrMsgM ()
tell [String
"Warning: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Module -> String
moduleString (Interface -> Module
ifaceMod Interface
iface) String -> String -> String
forall a. [a] -> [a] -> [a]
++
            String
": could not find link destinations for:\n"String -> String -> String
forall a. [a] -> [a] -> [a]
++
            String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
"\n\t- "  (String
"" String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
strings) ]

    Interface -> ErrMsgM Interface
forall (m :: * -> *) a. Monad m => a -> m a
return (Interface -> ErrMsgM Interface) -> Interface -> ErrMsgM Interface
forall a b. (a -> b) -> a -> b
$ Interface
iface { ifaceRnDoc :: Documentation DocName
ifaceRnDoc         = Documentation DocName
finalModuleDoc,
                     ifaceRnDocMap :: Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
ifaceRnDocMap      = Map Name (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
rnDocMap,
                     ifaceRnArgMap :: Map
  Name
  (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
ifaceRnArgMap      = Map
  Name
  (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
rnArgMap,
                     ifaceRnExportItems :: [ExportItem DocNameI]
ifaceRnExportItems = [ExportItem DocNameI]
renamedExportItems,
                     ifaceRnOrphanInstances :: [DocInstance DocNameI]
ifaceRnOrphanInstances = [DocInstance DocNameI]
[(InstHead DocNameI,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
  Located DocName, Maybe Module)]
renamedOrphanInstances}


--------------------------------------------------------------------------------
-- Monad for renaming
--------------------------------------------------------------------------------


-- | The monad does two things for us: it passes around the environment for
-- renaming, and it returns a list of names which couldn't be found in
-- the environment.
newtype RnM a =
  RnM { RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn :: (Name -> (Bool, DocName))
                -- Name lookup function. The 'Bool' indicates that if the name
                -- was \"found\" in the environment.

             -> (a, [Name] -> [Name])
                -- Value returned, as well as a difference list of the names not
                -- found
      }

instance Monad RnM where
  RnM a
m >>= :: RnM a -> (a -> RnM b) -> RnM b
>>= a -> RnM b
k = ((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM (((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b)
-> ((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b
forall a b. (a -> b) -> a -> b
$ \Name -> (Bool, DocName)
lkp -> let (a
a, [Name] -> [Name]
out1) = RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
forall a.
RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn RnM a
m Name -> (Bool, DocName)
lkp
                              (b
b, [Name] -> [Name]
out2) = RnM b -> (Name -> (Bool, DocName)) -> (b, [Name] -> [Name])
forall a.
RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn (a -> RnM b
k a
a) Name -> (Bool, DocName)
lkp
                          in (b
b, [Name] -> [Name]
out1 ([Name] -> [Name]) -> ([Name] -> [Name]) -> [Name] -> [Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Name] -> [Name]
out2)

instance Functor RnM where
  fmap :: (a -> b) -> RnM a -> RnM b
fmap a -> b
f (RnM (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
lkp) = ((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM ((a -> b) -> (a, [Name] -> [Name]) -> (b, [Name] -> [Name])
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first a -> b
f ((a, [Name] -> [Name]) -> (b, [Name] -> [Name]))
-> ((Name -> (Bool, DocName)) -> (a, [Name] -> [Name]))
-> (Name -> (Bool, DocName))
-> (b, [Name] -> [Name])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
lkp)

instance Applicative RnM where
  pure :: a -> RnM a
pure a
a = ((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM ((a, [Name] -> [Name])
-> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
forall a b. a -> b -> a
const (a
a, [Name] -> [Name]
forall a. a -> a
id))
  RnM (a -> b)
mf <*> :: RnM (a -> b) -> RnM a -> RnM b
<*> RnM a
mx = ((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM (((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b)
-> ((Name -> (Bool, DocName)) -> (b, [Name] -> [Name])) -> RnM b
forall a b. (a -> b) -> a -> b
$ \Name -> (Bool, DocName)
lkp -> let (a -> b
f, [Name] -> [Name]
out1) = RnM (a -> b)
-> (Name -> (Bool, DocName)) -> (a -> b, [Name] -> [Name])
forall a.
RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn RnM (a -> b)
mf Name -> (Bool, DocName)
lkp
                                (a
x, [Name] -> [Name]
out2) = RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
forall a.
RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn RnM a
mx Name -> (Bool, DocName)
lkp
                            in (a -> b
f a
x, [Name] -> [Name]
out1 ([Name] -> [Name]) -> ([Name] -> [Name]) -> [Name] -> [Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Name] -> [Name]
out2)

-- | Look up a 'Name' in the renaming environment.
lookupRn :: Name -> RnM DocName
lookupRn :: Name -> RnM DocName
lookupRn Name
name = ((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
-> RnM DocName
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM (((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
 -> RnM DocName)
-> ((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
-> RnM DocName
forall a b. (a -> b) -> a -> b
$ \Name -> (Bool, DocName)
lkp ->
  case Name -> (Bool, DocName)
lkp Name
name of
    (Bool
False,DocName
maps_to) -> (DocName
maps_to, (Name
name Name -> [Name] -> [Name]
forall a. a -> [a] -> [a]
:))
    (Bool
True, DocName
maps_to) -> (DocName
maps_to, [Name] -> [Name]
forall a. a -> a
id)

-- | Look up a 'Name' in the renaming environment, but don't warn if you don't
-- find the name. Prefer to use 'lookupRn' whenever possible.
lookupRnNoWarn :: Name -> RnM DocName
lookupRnNoWarn :: Name -> RnM DocName
lookupRnNoWarn Name
name = ((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
-> RnM DocName
forall a.
((Name -> (Bool, DocName)) -> (a, [Name] -> [Name])) -> RnM a
RnM (((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
 -> RnM DocName)
-> ((Name -> (Bool, DocName)) -> (DocName, [Name] -> [Name]))
-> RnM DocName
forall a b. (a -> b) -> a -> b
$ \Name -> (Bool, DocName)
lkp -> ((Bool, DocName) -> DocName
forall a b. (a, b) -> b
snd (Name -> (Bool, DocName)
lkp Name
name), [Name] -> [Name]
forall a. a -> a
id)

-- | Run the renamer action using lookup in a 'LinkEnv' as the lookup function.
-- Returns the renamed value along with a list of `Name`'s that could not be
-- renamed because they weren't in the environment.
runRnFM :: LinkEnv -> RnM a -> (a, [Name])
runRnFM :: LinkEnv -> RnM a -> (a, [Name])
runRnFM LinkEnv
env RnM a
rn = let (a
x, [Name] -> [Name]
dlist) = RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
forall a.
RnM a -> (Name -> (Bool, DocName)) -> (a, [Name] -> [Name])
unRn RnM a
rn Name -> (Bool, DocName)
lkp in (a
x, [Name] -> [Name]
dlist [])
  where
    lkp :: Name -> (Bool, DocName)
lkp Name
n | Name -> Bool
isTyVarName Name
n = (Bool
True, Name -> DocName
Undocumented Name
n)
          | Bool
otherwise = case Name -> LinkEnv -> Maybe Module
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Name
n LinkEnv
env of
                          Maybe Module
Nothing  -> (Bool
False, Name -> DocName
Undocumented Name
n)
                          Just Module
mdl -> (Bool
True,  Name -> Module -> DocName
Documented Name
n Module
mdl)


--------------------------------------------------------------------------------
-- Renaming
--------------------------------------------------------------------------------


rename :: Name -> RnM DocName
rename :: Name -> RnM DocName
rename = Name -> RnM DocName
lookupRn


renameL :: Located Name -> RnM (Located DocName)
renameL :: Located Name -> RnM (Located DocName)
renameL = (Name -> RnM DocName) -> Located Name -> RnM (Located DocName)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Name -> RnM DocName
rename


renameExportItems :: [ExportItem GhcRn] -> RnM [ExportItem DocNameI]
renameExportItems :: [ExportItem GhcRn] -> RnM [ExportItem DocNameI]
renameExportItems = (ExportItem GhcRn -> RnM (ExportItem DocNameI))
-> [ExportItem GhcRn] -> RnM [ExportItem DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ExportItem GhcRn -> RnM (ExportItem DocNameI)
renameExportItem


renameDocForDecl :: DocForDecl Name -> RnM (DocForDecl DocName)
renameDocForDecl :: DocForDecl Name -> RnM (DocForDecl DocName)
renameDocForDecl (Documentation Name
doc, Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
fnArgsDoc) =
  (,) (Documentation DocName
 -> Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
 -> DocForDecl DocName)
-> RnM (Documentation DocName)
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
      -> DocForDecl DocName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Documentation Name -> RnM (Documentation DocName)
renameDocumentation Documentation Name
doc RnM
  (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
   -> DocForDecl DocName)
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> RnM (DocForDecl DocName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
renameFnArgsDoc Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
fnArgsDoc


renameDocumentation :: Documentation Name -> RnM (Documentation DocName)
renameDocumentation :: Documentation Name -> RnM (Documentation DocName)
renameDocumentation (Documentation Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
mDoc Maybe (Doc Name)
mWarning) =
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
-> Maybe (Doc DocName) -> Documentation DocName
forall name.
Maybe (MDoc name) -> Maybe (Doc name) -> Documentation name
Documentation (Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
 -> Maybe (Doc DocName) -> Documentation DocName)
-> RnM
     (Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> RnM (Maybe (Doc DocName) -> Documentation DocName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
 -> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
mDoc RnM (Maybe (Doc DocName) -> Documentation DocName)
-> RnM (Maybe (Doc DocName)) -> RnM (Documentation DocName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Doc Name -> RnM (Doc DocName))
-> Maybe (Doc Name) -> RnM (Maybe (Doc DocName))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Doc Name -> RnM (Doc DocName)
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc Maybe (Doc Name)
mWarning


renameLDocHsSyn :: LHsDocString -> RnM LHsDocString
renameLDocHsSyn :: LHsDocString -> RnM LHsDocString
renameLDocHsSyn = LHsDocString -> RnM LHsDocString
forall (m :: * -> *) a. Monad m => a -> m a
return


renameDoc :: Traversable t => t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc :: t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc = (Wrap Name -> RnM (Wrap DocName))
-> t (Wrap Name) -> RnM (t (Wrap DocName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((Name -> RnM DocName) -> Wrap Name -> RnM (Wrap DocName)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Name -> RnM DocName
rename)

renameFnArgsDoc :: FnArgsDoc Name -> RnM (FnArgsDoc DocName)
renameFnArgsDoc :: Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
renameFnArgsDoc = (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
 -> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Map Int (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc


renameLType :: LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType :: LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType = (HsType GhcRn -> RnM (HsType DocNameI))
-> LHsType GhcRn -> RnM (LHsType DocNameI)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HsType GhcRn -> RnM (HsType DocNameI)
renameType

renameLTypeArg :: LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI)
renameLTypeArg :: LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI)
renameLTypeArg (HsValArg LHsType GhcRn
ty) = do { LHsType DocNameI
ty' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty
                                     ; LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI))
-> LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall a b. (a -> b) -> a -> b
$ LHsType DocNameI -> LHsTypeArg DocNameI
forall tm ty. tm -> HsArg tm ty
HsValArg LHsType DocNameI
ty' }
renameLTypeArg (HsTypeArg SrcSpan
l LHsType GhcRn
ki) = do { LHsType DocNameI
ki' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind LHsType GhcRn
ki
                                     ; LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI))
-> LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> LHsType DocNameI -> LHsTypeArg DocNameI
forall tm ty. SrcSpan -> ty -> HsArg tm ty
HsTypeArg SrcSpan
l LHsType DocNameI
ki' }
renameLTypeArg (HsArgPar SrcSpan
sp) = LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI))
-> LHsTypeArg DocNameI -> RnM (LHsTypeArg DocNameI)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> LHsTypeArg DocNameI
forall tm ty. SrcSpan -> HsArg tm ty
HsArgPar SrcSpan
sp

renameLSigType :: LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType :: LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType = (LHsType GhcRn -> RnM (LHsType DocNameI))
-> LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
forall in_thing out_thing.
(in_thing -> RnM out_thing)
-> HsImplicitBndrs GhcRn in_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType

renameLSigWcType :: LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
renameLSigWcType :: LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
renameLSigWcType = (LHsSigType GhcRn -> RnM (LHsSigType DocNameI))
-> LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
forall in_thing out_thing.
(in_thing -> RnM out_thing)
-> HsWildCardBndrs GhcRn in_thing
-> RnM (HsWildCardBndrs DocNameI out_thing)
renameWc ((LHsType GhcRn -> RnM (LHsType DocNameI))
-> LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
forall in_thing out_thing.
(in_thing -> RnM out_thing)
-> HsImplicitBndrs GhcRn in_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType)

renameLKind :: LHsKind GhcRn -> RnM (LHsKind DocNameI)
renameLKind :: LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind = LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType

renameMaybeLKind :: Maybe (LHsKind GhcRn) -> RnM (Maybe (LHsKind DocNameI))
renameMaybeLKind :: Maybe (LHsType GhcRn) -> RnM (Maybe (LHsType DocNameI))
renameMaybeLKind = (LHsType GhcRn -> RnM (LHsType DocNameI))
-> Maybe (LHsType GhcRn) -> RnM (Maybe (LHsType DocNameI))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind

renameFamilyResultSig :: LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)
renameFamilyResultSig :: LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)
renameFamilyResultSig (L SrcSpan
loc (NoSig XNoSig GhcRn
_))
    = LFamilyResultSig DocNameI -> RnM (LFamilyResultSig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> FamilyResultSig DocNameI -> LFamilyResultSig DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (XNoSig DocNameI -> FamilyResultSig DocNameI
forall pass. XNoSig pass -> FamilyResultSig pass
NoSig NoExtField
XNoSig DocNameI
noExtField))
renameFamilyResultSig (L SrcSpan
loc (KindSig XCKindSig GhcRn
_ LHsType GhcRn
ki))
    = do { LHsType DocNameI
ki' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind LHsType GhcRn
ki
         ; LFamilyResultSig DocNameI -> RnM (LFamilyResultSig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> FamilyResultSig DocNameI -> LFamilyResultSig DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (XCKindSig DocNameI -> LHsType DocNameI -> FamilyResultSig DocNameI
forall pass. XCKindSig pass -> LHsKind pass -> FamilyResultSig pass
KindSig NoExtField
XCKindSig DocNameI
noExtField LHsType DocNameI
ki')) }
renameFamilyResultSig (L SrcSpan
loc (TyVarSig XTyVarSig GhcRn
_ LHsTyVarBndr GhcRn
bndr))
    = do { LHsTyVarBndr DocNameI
bndr' <- LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr LHsTyVarBndr GhcRn
bndr
         ; LFamilyResultSig DocNameI -> RnM (LFamilyResultSig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> FamilyResultSig DocNameI -> LFamilyResultSig DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (XTyVarSig DocNameI
-> LHsTyVarBndr DocNameI -> FamilyResultSig DocNameI
forall pass.
XTyVarSig pass -> LHsTyVarBndr pass -> FamilyResultSig pass
TyVarSig NoExtField
XTyVarSig DocNameI
noExtField LHsTyVarBndr DocNameI
bndr')) }
renameFamilyResultSig (L SrcSpan
_ (XFamilyResultSig XXFamilyResultSig GhcRn
nec)) = NoExtCon -> RnM (LFamilyResultSig DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXFamilyResultSig GhcRn
nec

renameInjectivityAnn :: LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI)
renameInjectivityAnn :: LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI)
renameInjectivityAnn (L SrcSpan
loc (InjectivityAnn Located (IdP GhcRn)
lhs [Located (IdP GhcRn)]
rhs))
    = do { Located DocName
lhs' <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lhs
         ; [Located DocName]
rhs' <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
rhs
         ; LInjectivityAnn DocNameI -> RnM (LInjectivityAnn DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> InjectivityAnn DocNameI -> LInjectivityAnn DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (Located (IdP DocNameI)
-> [Located (IdP DocNameI)] -> InjectivityAnn DocNameI
forall pass.
Located (IdP pass) -> [Located (IdP pass)] -> InjectivityAnn pass
InjectivityAnn Located (IdP DocNameI)
Located DocName
lhs' [Located (IdP DocNameI)]
[Located DocName]
rhs')) }

renameMaybeInjectivityAnn :: Maybe (LInjectivityAnn GhcRn)
                          -> RnM (Maybe (LInjectivityAnn DocNameI))
renameMaybeInjectivityAnn :: Maybe (LInjectivityAnn GhcRn)
-> RnM (Maybe (LInjectivityAnn DocNameI))
renameMaybeInjectivityAnn = (LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI))
-> Maybe (LInjectivityAnn GhcRn)
-> RnM (Maybe (LInjectivityAnn DocNameI))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse LInjectivityAnn GhcRn -> RnM (LInjectivityAnn DocNameI)
renameInjectivityAnn

renameType :: HsType GhcRn -> RnM (HsType DocNameI)
renameType :: HsType GhcRn -> RnM (HsType DocNameI)
renameType HsType GhcRn
t = case HsType GhcRn
t of
  HsForAllTy { hst_fvf :: forall pass. HsType pass -> ForallVisFlag
hst_fvf = ForallVisFlag
fvf, hst_bndrs :: forall pass. HsType pass -> [LHsTyVarBndr pass]
hst_bndrs = [LHsTyVarBndr GhcRn]
tyvars, hst_body :: forall pass. HsType pass -> LHsType pass
hst_body = LHsType GhcRn
ltype } -> do
    [LHsTyVarBndr DocNameI]
tyvars'   <- (LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI))
-> [LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr [LHsTyVarBndr GhcRn]
tyvars
    LHsType DocNameI
ltype'    <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ltype
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsForAllTy :: forall pass.
XForAllTy pass
-> ForallVisFlag
-> [LHsTyVarBndr pass]
-> LHsType pass
-> HsType pass
HsForAllTy { hst_fvf :: ForallVisFlag
hst_fvf = ForallVisFlag
fvf, hst_xforall :: XForAllTy DocNameI
hst_xforall = NoExtField
XForAllTy DocNameI
noExtField
                       , hst_bndrs :: [LHsTyVarBndr DocNameI]
hst_bndrs = [LHsTyVarBndr DocNameI]
tyvars', hst_body :: LHsType DocNameI
hst_body = LHsType DocNameI
ltype' })

  HsQualTy { hst_ctxt :: forall pass. HsType pass -> LHsContext pass
hst_ctxt = LHsContext GhcRn
lcontext , hst_body :: forall pass. HsType pass -> LHsType pass
hst_body = LHsType GhcRn
ltype } -> do
    Located [LHsType DocNameI]
lcontext' <- LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext LHsContext GhcRn
lcontext
    LHsType DocNameI
ltype'    <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ltype
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsQualTy :: forall pass.
XQualTy pass -> LHsContext pass -> LHsType pass -> HsType pass
HsQualTy { hst_xqual :: XQualTy DocNameI
hst_xqual = NoExtField
XQualTy DocNameI
noExtField, hst_ctxt :: Located [LHsType DocNameI]
hst_ctxt = Located [LHsType DocNameI]
lcontext', hst_body :: LHsType DocNameI
hst_body = LHsType DocNameI
ltype' })

  HsTyVar XTyVar GhcRn
_ PromotionFlag
ip (L SrcSpan
l IdP GhcRn
n) -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType DocNameI -> RnM (HsType DocNameI))
-> (DocName -> HsType DocNameI) -> DocName -> RnM (HsType DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XTyVar DocNameI
-> PromotionFlag -> Located (IdP DocNameI) -> HsType DocNameI
forall pass.
XTyVar pass -> PromotionFlag -> Located (IdP pass) -> HsType pass
HsTyVar NoExtField
XTyVar DocNameI
noExtField PromotionFlag
ip (Located DocName -> HsType DocNameI)
-> (DocName -> Located DocName) -> DocName -> HsType DocNameI
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> DocName -> Located DocName
forall l e. l -> e -> GenLocated l e
L SrcSpan
l (DocName -> RnM (HsType DocNameI))
-> RnM DocName -> RnM (HsType DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Name -> RnM DocName
rename IdP GhcRn
Name
n
  HsBangTy XBangTy GhcRn
_ HsSrcBang
b LHsType GhcRn
ltype -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType DocNameI -> RnM (HsType DocNameI))
-> (LHsType DocNameI -> HsType DocNameI)
-> LHsType DocNameI
-> RnM (HsType DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XBangTy DocNameI
-> HsSrcBang -> LHsType DocNameI -> HsType DocNameI
forall pass.
XBangTy pass -> HsSrcBang -> LHsType pass -> HsType pass
HsBangTy NoExtField
XBangTy DocNameI
noExtField HsSrcBang
b (LHsType DocNameI -> RnM (HsType DocNameI))
-> RnM (LHsType DocNameI) -> RnM (HsType DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ltype

  HsStarTy XStarTy GhcRn
_ Bool
isUni -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XStarTy DocNameI -> Bool -> HsType DocNameI
forall pass. XStarTy pass -> Bool -> HsType pass
HsStarTy NoExtField
XStarTy DocNameI
noExtField Bool
isUni)

  HsAppTy XAppTy GhcRn
_ LHsType GhcRn
a LHsType GhcRn
b -> do
    LHsType DocNameI
a' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
a
    LHsType DocNameI
b' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
b
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XAppTy DocNameI
-> LHsType DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass.
XAppTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppTy NoExtField
XAppTy DocNameI
noExtField LHsType DocNameI
a' LHsType DocNameI
b')

  HsAppKindTy XAppKindTy GhcRn
_ LHsType GhcRn
a LHsType GhcRn
b -> do
    LHsType DocNameI
a' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
a
    LHsType DocNameI
b' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind LHsType GhcRn
b
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XAppKindTy DocNameI
-> LHsType DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass.
XAppKindTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsAppKindTy NoExtField
XAppKindTy DocNameI
noExtField LHsType DocNameI
a' LHsType DocNameI
b')

  HsFunTy XFunTy GhcRn
_ LHsType GhcRn
a LHsType GhcRn
b -> do
    LHsType DocNameI
a' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
a
    LHsType DocNameI
b' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
b
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XFunTy DocNameI
-> LHsType DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass.
XFunTy pass -> LHsType pass -> LHsType pass -> HsType pass
HsFunTy NoExtField
XFunTy DocNameI
noExtField LHsType DocNameI
a' LHsType DocNameI
b')

  HsListTy XListTy GhcRn
_ LHsType GhcRn
ty -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType DocNameI -> RnM (HsType DocNameI))
-> (LHsType DocNameI -> HsType DocNameI)
-> LHsType DocNameI
-> RnM (HsType DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (XListTy DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass. XListTy pass -> LHsType pass -> HsType pass
HsListTy NoExtField
XListTy DocNameI
noExtField) (LHsType DocNameI -> RnM (HsType DocNameI))
-> RnM (LHsType DocNameI) -> RnM (HsType DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty
  HsIParamTy XIParamTy GhcRn
_ Located HsIPName
n LHsType GhcRn
ty -> (LHsType DocNameI -> HsType DocNameI)
-> RnM (LHsType DocNameI) -> RnM (HsType DocNameI)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (XIParamTy DocNameI
-> Located HsIPName -> LHsType DocNameI -> HsType DocNameI
forall pass.
XIParamTy pass -> Located HsIPName -> LHsType pass -> HsType pass
HsIParamTy NoExtField
XIParamTy DocNameI
noExtField Located HsIPName
n) (LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty)

  HsTupleTy XTupleTy GhcRn
_ HsTupleSort
b [LHsType GhcRn]
ts -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType DocNameI -> RnM (HsType DocNameI))
-> ([LHsType DocNameI] -> HsType DocNameI)
-> [LHsType DocNameI]
-> RnM (HsType DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XTupleTy DocNameI
-> HsTupleSort -> [LHsType DocNameI] -> HsType DocNameI
forall pass.
XTupleTy pass -> HsTupleSort -> [LHsType pass] -> HsType pass
HsTupleTy NoExtField
XTupleTy DocNameI
noExtField HsTupleSort
b ([LHsType DocNameI] -> RnM (HsType DocNameI))
-> RnM [LHsType DocNameI] -> RnM (HsType DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
ts
  HsSumTy XSumTy GhcRn
_ [LHsType GhcRn]
ts -> XSumTy DocNameI -> [LHsType DocNameI] -> HsType DocNameI
forall pass. XSumTy pass -> [LHsType pass] -> HsType pass
HsSumTy NoExtField
XSumTy DocNameI
noExtField ([LHsType DocNameI] -> HsType DocNameI)
-> RnM [LHsType DocNameI] -> RnM (HsType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
ts

  HsOpTy XOpTy GhcRn
_ LHsType GhcRn
a (L SrcSpan
loc IdP GhcRn
op) LHsType GhcRn
b -> do
    DocName
op' <- Name -> RnM DocName
rename IdP GhcRn
Name
op
    LHsType DocNameI
a'  <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
a
    LHsType DocNameI
b'  <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
b
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XOpTy DocNameI
-> LHsType DocNameI
-> Located (IdP DocNameI)
-> LHsType DocNameI
-> HsType DocNameI
forall pass.
XOpTy pass
-> LHsType pass
-> Located (IdP pass)
-> LHsType pass
-> HsType pass
HsOpTy NoExtField
XOpTy DocNameI
noExtField LHsType DocNameI
a' (SrcSpan -> DocName -> Located DocName
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc DocName
op') LHsType DocNameI
b')

  HsParTy XParTy GhcRn
_ LHsType GhcRn
ty -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType DocNameI -> RnM (HsType DocNameI))
-> (LHsType DocNameI -> HsType DocNameI)
-> LHsType DocNameI
-> RnM (HsType DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (XParTy DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass. XParTy pass -> LHsType pass -> HsType pass
HsParTy NoExtField
XParTy DocNameI
noExtField) (LHsType DocNameI -> RnM (HsType DocNameI))
-> RnM (LHsType DocNameI) -> RnM (HsType DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty

  HsKindSig XKindSig GhcRn
_ LHsType GhcRn
ty LHsType GhcRn
k -> do
    LHsType DocNameI
ty' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty
    LHsType DocNameI
k' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind LHsType GhcRn
k
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XKindSig DocNameI
-> LHsType DocNameI -> LHsType DocNameI -> HsType DocNameI
forall pass.
XKindSig pass -> LHsType pass -> LHsType pass -> HsType pass
HsKindSig NoExtField
XKindSig DocNameI
noExtField LHsType DocNameI
ty' LHsType DocNameI
k')

  HsDocTy XDocTy GhcRn
_ LHsType GhcRn
ty LHsDocString
doc -> do
    LHsType DocNameI
ty' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
ty
    LHsDocString
doc' <- LHsDocString -> RnM LHsDocString
renameLDocHsSyn LHsDocString
doc
    HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XDocTy DocNameI
-> LHsType DocNameI -> LHsDocString -> HsType DocNameI
forall pass.
XDocTy pass -> LHsType pass -> LHsDocString -> HsType pass
HsDocTy NoExtField
XDocTy DocNameI
noExtField LHsType DocNameI
ty' LHsDocString
doc')

  HsTyLit XTyLit GhcRn
_ HsTyLit
x -> HsType DocNameI -> RnM (HsType DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XTyLit DocNameI -> HsTyLit -> HsType DocNameI
forall pass. XTyLit pass -> HsTyLit -> HsType pass
HsTyLit NoExtField
XTyLit DocNameI
noExtField HsTyLit
x)

  HsRecTy XRecTy GhcRn
_ [LConDeclField GhcRn]
a               -> XRecTy DocNameI -> [LConDeclField DocNameI] -> HsType DocNameI
forall pass. XRecTy pass -> [LConDeclField pass] -> HsType pass
HsRecTy NoExtField
XRecTy DocNameI
noExtField ([LConDeclField DocNameI] -> HsType DocNameI)
-> RnM [LConDeclField DocNameI] -> RnM (HsType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LConDeclField GhcRn -> RnM (LConDeclField DocNameI))
-> [LConDeclField GhcRn] -> RnM [LConDeclField DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LConDeclField GhcRn -> RnM (LConDeclField DocNameI)
renameConDeclFieldField [LConDeclField GhcRn]
a
  (XHsType (NHsCoreTy a))   -> HsType DocNameI -> RnM (HsType DocNameI)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (XXType DocNameI -> HsType DocNameI
forall pass. XXType pass -> HsType pass
XHsType (Type -> NewHsTypeX
NHsCoreTy Type
a))
  HsExplicitListTy XExplicitListTy GhcRn
i PromotionFlag
a [LHsType GhcRn]
b  -> XExplicitListTy DocNameI
-> PromotionFlag -> [LHsType DocNameI] -> HsType DocNameI
forall pass.
XExplicitListTy pass
-> PromotionFlag -> [LHsType pass] -> HsType pass
HsExplicitListTy XExplicitListTy GhcRn
XExplicitListTy DocNameI
i PromotionFlag
a ([LHsType DocNameI] -> HsType DocNameI)
-> RnM [LHsType DocNameI] -> RnM (HsType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
b
  HsExplicitTupleTy XExplicitTupleTy GhcRn
a [LHsType GhcRn]
b   -> XExplicitTupleTy DocNameI -> [LHsType DocNameI] -> HsType DocNameI
forall pass. XExplicitTupleTy pass -> [LHsType pass] -> HsType pass
HsExplicitTupleTy XExplicitTupleTy GhcRn
XExplicitTupleTy DocNameI
a ([LHsType DocNameI] -> HsType DocNameI)
-> RnM [LHsType DocNameI] -> RnM (HsType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
b
  HsSpliceTy XSpliceTy GhcRn
_ HsSplice GhcRn
s          -> HsSplice GhcRn -> RnM (HsType DocNameI)
renameHsSpliceTy HsSplice GhcRn
s
  HsWildCardTy XWildCardTy GhcRn
a          -> HsType DocNameI -> RnM (HsType DocNameI)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (XWildCardTy DocNameI -> HsType DocNameI
forall pass. XWildCardTy pass -> HsType pass
HsWildCardTy XWildCardTy GhcRn
XWildCardTy DocNameI
a)

-- | Rename splices, but _only_ those that turn out to be for types.
-- I think this is actually safe for our possible inputs:
--
--  * the input is from after GHC's renamer, so should have an 'HsSpliced'
--  * the input is typechecked, and only 'HsSplicedTy' should get through that
--
renameHsSpliceTy :: HsSplice GhcRn -> RnM (HsType DocNameI)
renameHsSpliceTy :: HsSplice GhcRn -> RnM (HsType DocNameI)
renameHsSpliceTy (HsSpliced XSpliced GhcRn
_ ThModFinalizers
_ (HsSplicedTy HsType GhcRn
t)) = HsType GhcRn -> RnM (HsType DocNameI)
renameType HsType GhcRn
t
renameHsSpliceTy (HsSpliced XSpliced GhcRn
_ ThModFinalizers
_ HsSplicedThing GhcRn
_) = String -> RnM (HsType DocNameI)
forall a. HasCallStack => String -> a
error String
"renameHsSpliceTy: not an HsSplicedTy"
renameHsSpliceTy HsSplice GhcRn
_ = String -> RnM (HsType DocNameI)
forall a. HasCallStack => String -> a
error String
"renameHsSpliceTy: not an HsSpliced"

renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars :: LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars (HsQTvs { hsq_explicit :: forall pass. LHsQTyVars pass -> [LHsTyVarBndr pass]
hsq_explicit = [LHsTyVarBndr GhcRn]
tvs })
  = do { [LHsTyVarBndr DocNameI]
tvs' <- (LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI))
-> [LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr [LHsTyVarBndr GhcRn]
tvs
       ; LHsQTyVars DocNameI -> RnM (LHsQTyVars DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsQTvs :: forall pass. XHsQTvs pass -> [LHsTyVarBndr pass] -> LHsQTyVars pass
HsQTvs { hsq_ext :: XHsQTvs DocNameI
hsq_ext = NoExtField
XHsQTvs DocNameI
noExtField
                        , hsq_explicit :: [LHsTyVarBndr DocNameI]
hsq_explicit = [LHsTyVarBndr DocNameI]
tvs' }) }
renameLHsQTyVars (XLHsQTyVars XXLHsQTyVars GhcRn
nec) = NoExtCon -> RnM (LHsQTyVars DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXLHsQTyVars GhcRn
nec

renameLTyVarBndr :: LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr :: LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr (L SrcSpan
loc (UserTyVar XUserTyVar GhcRn
x (L SrcSpan
l IdP GhcRn
n)))
  = do { DocName
n' <- Name -> RnM DocName
rename IdP GhcRn
Name
n
       ; LHsTyVarBndr DocNameI -> RnM (LHsTyVarBndr DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> HsTyVarBndr DocNameI -> LHsTyVarBndr DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (XUserTyVar DocNameI
-> Located (IdP DocNameI) -> HsTyVarBndr DocNameI
forall pass.
XUserTyVar pass -> Located (IdP pass) -> HsTyVarBndr pass
UserTyVar XUserTyVar GhcRn
XUserTyVar DocNameI
x (SrcSpan -> DocName -> Located DocName
forall l e. l -> e -> GenLocated l e
L SrcSpan
l DocName
n'))) }
renameLTyVarBndr (L SrcSpan
loc (KindedTyVar XKindedTyVar GhcRn
x (L SrcSpan
lv IdP GhcRn
n) LHsType GhcRn
kind))
  = do { DocName
n' <- Name -> RnM DocName
rename IdP GhcRn
Name
n
       ; LHsType DocNameI
kind' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLKind LHsType GhcRn
kind
       ; LHsTyVarBndr DocNameI -> RnM (LHsTyVarBndr DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> HsTyVarBndr DocNameI -> LHsTyVarBndr DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (XKindedTyVar DocNameI
-> Located (IdP DocNameI)
-> LHsType DocNameI
-> HsTyVarBndr DocNameI
forall pass.
XKindedTyVar pass
-> Located (IdP pass) -> LHsKind pass -> HsTyVarBndr pass
KindedTyVar XKindedTyVar GhcRn
XKindedTyVar DocNameI
x (SrcSpan -> DocName -> Located DocName
forall l e. l -> e -> GenLocated l e
L SrcSpan
lv DocName
n') LHsType DocNameI
kind')) }
renameLTyVarBndr (L SrcSpan
_ (XTyVarBndr XXTyVarBndr GhcRn
nec)) = NoExtCon -> RnM (LHsTyVarBndr DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXTyVarBndr GhcRn
nec

renameLContext :: Located [LHsType GhcRn] -> RnM (Located [LHsType DocNameI])
renameLContext :: LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext (L SrcSpan
loc [LHsType GhcRn]
context) = do
  [LHsType DocNameI]
context' <- (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
context
  Located [LHsType DocNameI] -> RnM (Located [LHsType DocNameI])
forall (m :: * -> *) a. Monad m => a -> m a
return (SrcSpan -> [LHsType DocNameI] -> Located [LHsType DocNameI]
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc [LHsType DocNameI]
context')

renameInstHead :: InstHead GhcRn -> RnM (InstHead DocNameI)
renameInstHead :: InstHead GhcRn -> RnM (InstHead DocNameI)
renameInstHead InstHead {[HsType GhcRn]
IdP GhcRn
InstType GhcRn
ihdInstType :: forall name. InstHead name -> InstType name
ihdTypes :: forall name. InstHead name -> [HsType name]
ihdClsName :: forall name. InstHead name -> IdP name
ihdInstType :: InstType GhcRn
ihdTypes :: [HsType GhcRn]
ihdClsName :: IdP GhcRn
..} = do
  DocName
cname <- Name -> RnM DocName
rename IdP GhcRn
Name
ihdClsName
  [HsType DocNameI]
types <- (HsType GhcRn -> RnM (HsType DocNameI))
-> [HsType GhcRn] -> RnM [HsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HsType GhcRn -> RnM (HsType DocNameI)
renameType [HsType GhcRn]
ihdTypes
  InstType DocNameI
itype <- case InstType GhcRn
ihdInstType of
    ClassInst { [Sig GhcRn]
[HsType GhcRn]
[PseudoFamilyDecl GhcRn]
LHsQTyVars GhcRn
clsiAssocTys :: forall name. InstType name -> [PseudoFamilyDecl name]
clsiSigs :: forall name. InstType name -> [Sig name]
clsiTyVars :: forall name. InstType name -> LHsQTyVars name
clsiCtx :: forall name. InstType name -> [HsType name]
clsiAssocTys :: [PseudoFamilyDecl GhcRn]
clsiSigs :: [Sig GhcRn]
clsiTyVars :: LHsQTyVars GhcRn
clsiCtx :: [HsType GhcRn]
.. } -> [HsType DocNameI]
-> LHsQTyVars DocNameI
-> [Sig DocNameI]
-> [PseudoFamilyDecl DocNameI]
-> InstType DocNameI
forall name.
[HsType name]
-> LHsQTyVars name
-> [Sig name]
-> [PseudoFamilyDecl name]
-> InstType name
ClassInst
        ([HsType DocNameI]
 -> LHsQTyVars DocNameI
 -> [Sig DocNameI]
 -> [PseudoFamilyDecl DocNameI]
 -> InstType DocNameI)
-> RnM [HsType DocNameI]
-> RnM
     (LHsQTyVars DocNameI
      -> [Sig DocNameI]
      -> [PseudoFamilyDecl DocNameI]
      -> InstType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HsType GhcRn -> RnM (HsType DocNameI))
-> [HsType GhcRn] -> RnM [HsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HsType GhcRn -> RnM (HsType DocNameI)
renameType [HsType GhcRn]
clsiCtx
        RnM
  (LHsQTyVars DocNameI
   -> [Sig DocNameI]
   -> [PseudoFamilyDecl DocNameI]
   -> InstType DocNameI)
-> RnM (LHsQTyVars DocNameI)
-> RnM
     ([Sig DocNameI]
      -> [PseudoFamilyDecl DocNameI] -> InstType DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
clsiTyVars
        RnM
  ([Sig DocNameI]
   -> [PseudoFamilyDecl DocNameI] -> InstType DocNameI)
-> RnM [Sig DocNameI]
-> RnM ([PseudoFamilyDecl DocNameI] -> InstType DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Sig GhcRn -> RnM (Sig DocNameI))
-> [Sig GhcRn] -> RnM [Sig DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Sig GhcRn -> RnM (Sig DocNameI)
renameSig [Sig GhcRn]
clsiSigs
        RnM ([PseudoFamilyDecl DocNameI] -> InstType DocNameI)
-> RnM [PseudoFamilyDecl DocNameI] -> RnM (InstType DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PseudoFamilyDecl GhcRn -> RnM (PseudoFamilyDecl DocNameI))
-> [PseudoFamilyDecl GhcRn] -> RnM [PseudoFamilyDecl DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PseudoFamilyDecl GhcRn -> RnM (PseudoFamilyDecl DocNameI)
renamePseudoFamilyDecl [PseudoFamilyDecl GhcRn]
clsiAssocTys
    TypeInst  Maybe (HsType GhcRn)
ts -> Maybe (HsType DocNameI) -> InstType DocNameI
forall name. Maybe (HsType name) -> InstType name
TypeInst  (Maybe (HsType DocNameI) -> InstType DocNameI)
-> RnM (Maybe (HsType DocNameI)) -> RnM (InstType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (HsType GhcRn -> RnM (HsType DocNameI))
-> Maybe (HsType GhcRn) -> RnM (Maybe (HsType DocNameI))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse HsType GhcRn -> RnM (HsType DocNameI)
renameType Maybe (HsType GhcRn)
ts
    DataInst  TyClDecl GhcRn
dd -> TyClDecl DocNameI -> InstType DocNameI
forall name. TyClDecl name -> InstType name
DataInst  (TyClDecl DocNameI -> InstType DocNameI)
-> RnM (TyClDecl DocNameI) -> RnM (InstType DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TyClDecl GhcRn -> RnM (TyClDecl DocNameI)
renameTyClD TyClDecl GhcRn
dd
  InstHead DocNameI -> RnM (InstHead DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return InstHead :: forall name.
IdP name -> [HsType name] -> InstType name -> InstHead name
InstHead
    { ihdClsName :: IdP DocNameI
ihdClsName = IdP DocNameI
DocName
cname
    , ihdTypes :: [HsType DocNameI]
ihdTypes = [HsType DocNameI]
types
    , ihdInstType :: InstType DocNameI
ihdInstType = InstType DocNameI
itype
    }

renameLDecl :: LHsDecl GhcRn -> RnM (LHsDecl DocNameI)
renameLDecl :: LHsDecl GhcRn -> RnM (LHsDecl DocNameI)
renameLDecl (L SrcSpan
loc HsDecl GhcRn
d) = LHsDecl DocNameI -> RnM (LHsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsDecl DocNameI -> RnM (LHsDecl DocNameI))
-> (HsDecl DocNameI -> LHsDecl DocNameI)
-> HsDecl DocNameI
-> RnM (LHsDecl DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> HsDecl DocNameI -> LHsDecl DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (HsDecl DocNameI -> RnM (LHsDecl DocNameI))
-> RnM (HsDecl DocNameI) -> RnM (LHsDecl DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HsDecl GhcRn -> RnM (HsDecl DocNameI)
renameDecl HsDecl GhcRn
d

renamePats :: [(HsDecl GhcRn, DocForDecl Name)] -> RnM [(HsDecl DocNameI, DocForDecl DocName)]
renamePats :: [(HsDecl GhcRn, DocForDecl Name)]
-> RnM [(HsDecl DocNameI, DocForDecl DocName)]
renamePats = ((HsDecl GhcRn, DocForDecl Name)
 -> RnM (HsDecl DocNameI, DocForDecl DocName))
-> [(HsDecl GhcRn, DocForDecl Name)]
-> RnM [(HsDecl DocNameI, DocForDecl DocName)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM
  (\(HsDecl GhcRn
d,DocForDecl Name
doc) -> do { HsDecl DocNameI
d'   <- HsDecl GhcRn -> RnM (HsDecl DocNameI)
renameDecl HsDecl GhcRn
d
                  ; DocForDecl DocName
doc' <- DocForDecl Name -> RnM (DocForDecl DocName)
renameDocForDecl DocForDecl Name
doc
                  ; (HsDecl DocNameI, DocForDecl DocName)
-> RnM (HsDecl DocNameI, DocForDecl DocName)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsDecl DocNameI
d',DocForDecl DocName
doc')})

renameDecl :: HsDecl GhcRn -> RnM (HsDecl DocNameI)
renameDecl :: HsDecl GhcRn -> RnM (HsDecl DocNameI)
renameDecl HsDecl GhcRn
decl = case HsDecl GhcRn
decl of
  TyClD XTyClD GhcRn
_ TyClDecl GhcRn
d -> do
    TyClDecl DocNameI
d' <- TyClDecl GhcRn -> RnM (TyClDecl DocNameI)
renameTyClD TyClDecl GhcRn
d
    HsDecl DocNameI -> RnM (HsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XTyClD DocNameI -> TyClDecl DocNameI -> HsDecl DocNameI
forall p. XTyClD p -> TyClDecl p -> HsDecl p
TyClD NoExtField
XTyClD DocNameI
noExtField TyClDecl DocNameI
d')
  SigD XSigD GhcRn
_ Sig GhcRn
s -> do
    Sig DocNameI
s' <- Sig GhcRn -> RnM (Sig DocNameI)
renameSig Sig GhcRn
s
    HsDecl DocNameI -> RnM (HsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XSigD DocNameI -> Sig DocNameI -> HsDecl DocNameI
forall p. XSigD p -> Sig p -> HsDecl p
SigD NoExtField
XSigD DocNameI
noExtField Sig DocNameI
s')
  ForD XForD GhcRn
_ ForeignDecl GhcRn
d -> do
    ForeignDecl DocNameI
d' <- ForeignDecl GhcRn -> RnM (ForeignDecl DocNameI)
renameForD ForeignDecl GhcRn
d
    HsDecl DocNameI -> RnM (HsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XForD DocNameI -> ForeignDecl DocNameI -> HsDecl DocNameI
forall p. XForD p -> ForeignDecl p -> HsDecl p
ForD NoExtField
XForD DocNameI
noExtField ForeignDecl DocNameI
d')
  InstD XInstD GhcRn
_ InstDecl GhcRn
d -> do
    InstDecl DocNameI
d' <- InstDecl GhcRn -> RnM (InstDecl DocNameI)
renameInstD InstDecl GhcRn
d
    HsDecl DocNameI -> RnM (HsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XInstD DocNameI -> InstDecl DocNameI -> HsDecl DocNameI
forall p. XInstD p -> InstDecl p -> HsDecl p
InstD NoExtField
XInstD DocNameI
noExtField InstDecl DocNameI
d')
  DerivD XDerivD GhcRn
_ DerivDecl GhcRn
d -> do
    DerivDecl DocNameI
d' <- DerivDecl GhcRn -> RnM (DerivDecl DocNameI)
renameDerivD DerivDecl GhcRn
d
    HsDecl DocNameI -> RnM (HsDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XDerivD DocNameI -> DerivDecl DocNameI -> HsDecl DocNameI
forall p. XDerivD p -> DerivDecl p -> HsDecl p
DerivD NoExtField
XDerivD DocNameI
noExtField DerivDecl DocNameI
d')
  HsDecl GhcRn
_ -> String -> RnM (HsDecl DocNameI)
forall a. HasCallStack => String -> a
error String
"renameDecl"

renameLThing :: (a GhcRn -> RnM (a DocNameI)) -> Located (a GhcRn) -> RnM (Located (a DocNameI))
renameLThing :: (a GhcRn -> RnM (a DocNameI))
-> Located (a GhcRn) -> RnM (Located (a DocNameI))
renameLThing a GhcRn -> RnM (a DocNameI)
fn (L SrcSpan
loc a GhcRn
x) = Located (a DocNameI) -> RnM (Located (a DocNameI))
forall (m :: * -> *) a. Monad m => a -> m a
return (Located (a DocNameI) -> RnM (Located (a DocNameI)))
-> (a DocNameI -> Located (a DocNameI))
-> a DocNameI
-> RnM (Located (a DocNameI))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SrcSpan -> a DocNameI -> Located (a DocNameI)
forall l e. l -> e -> GenLocated l e
L SrcSpan
loc (a DocNameI -> RnM (Located (a DocNameI)))
-> RnM (a DocNameI) -> RnM (Located (a DocNameI))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< a GhcRn -> RnM (a DocNameI)
fn a GhcRn
x

renameTyClD :: TyClDecl GhcRn -> RnM (TyClDecl DocNameI)
renameTyClD :: TyClDecl GhcRn -> RnM (TyClDecl DocNameI)
renameTyClD TyClDecl GhcRn
d = case TyClDecl GhcRn
d of
--  TyFamily flav lname ltyvars kind tckind -> do
  FamDecl { tcdFam :: forall pass. TyClDecl pass -> FamilyDecl pass
tcdFam = FamilyDecl GhcRn
decl } -> do
    FamilyDecl DocNameI
decl' <- FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI)
renameFamilyDecl FamilyDecl GhcRn
decl
    TyClDecl DocNameI -> RnM (TyClDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (FamDecl :: forall pass. XFamDecl pass -> FamilyDecl pass -> TyClDecl pass
FamDecl { tcdFExt :: XFamDecl DocNameI
tcdFExt = NoExtField
XFamDecl DocNameI
noExtField, tcdFam :: FamilyDecl DocNameI
tcdFam = FamilyDecl DocNameI
decl' })

  SynDecl { tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP GhcRn)
lname, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
tyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
tcdRhs = LHsType GhcRn
rhs } -> do
    Located DocName
lname'    <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
    LHsQTyVars DocNameI
tyvars'   <- LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
tyvars
    LHsType DocNameI
rhs'     <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
rhs
    TyClDecl DocNameI -> RnM (TyClDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (SynDecl :: forall pass.
XSynDecl pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> LHsType pass
-> TyClDecl pass
SynDecl { tcdSExt :: XSynDecl DocNameI
tcdSExt = NoExtField
XSynDecl DocNameI
noExtField, tcdLName :: Located (IdP DocNameI)
tcdLName = Located (IdP DocNameI)
Located DocName
lname', tcdTyVars :: LHsQTyVars DocNameI
tcdTyVars = LHsQTyVars DocNameI
tyvars'
                    , tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdRhs :: LHsType DocNameI
tcdRhs = LHsType DocNameI
rhs' })

  DataDecl { tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP GhcRn)
lname, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
tyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
tcdDataDefn = HsDataDefn GhcRn
defn } -> do
    Located DocName
lname'    <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
    LHsQTyVars DocNameI
tyvars'   <- LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
tyvars
    HsDataDefn DocNameI
defn'     <- HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)
renameDataDefn HsDataDefn GhcRn
defn
    TyClDecl DocNameI -> RnM (TyClDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (DataDecl :: forall pass.
XDataDecl pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> HsDataDefn pass
-> TyClDecl pass
DataDecl { tcdDExt :: XDataDecl DocNameI
tcdDExt = NoExtField
XDataDecl DocNameI
noExtField, tcdLName :: Located (IdP DocNameI)
tcdLName = Located (IdP DocNameI)
Located DocName
lname', tcdTyVars :: LHsQTyVars DocNameI
tcdTyVars = LHsQTyVars DocNameI
tyvars'
                     , tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity, tcdDataDefn :: HsDataDefn DocNameI
tcdDataDefn = HsDataDefn DocNameI
defn' })

  ClassDecl { tcdCtxt :: forall pass. TyClDecl pass -> LHsContext pass
tcdCtxt = LHsContext GhcRn
lcontext, tcdLName :: forall pass. TyClDecl pass -> Located (IdP pass)
tcdLName = Located (IdP GhcRn)
lname, tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdTyVars = LHsQTyVars GhcRn
ltyvars, tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdFixity = LexicalFixity
fixity
            , tcdFDs :: forall pass. TyClDecl pass -> [LHsFunDep pass]
tcdFDs = [LHsFunDep GhcRn]
lfundeps, tcdSigs :: forall pass. TyClDecl pass -> [LSig pass]
tcdSigs = [LSig GhcRn]
lsigs, tcdATs :: forall pass. TyClDecl pass -> [LFamilyDecl pass]
tcdATs = [LFamilyDecl GhcRn]
ats, tcdATDefs :: forall pass. TyClDecl pass -> [LTyFamDefltDecl pass]
tcdATDefs = [LTyFamDefltDecl GhcRn]
at_defs } -> do
    Located [LHsType DocNameI]
lcontext' <- LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext LHsContext GhcRn
lcontext
    Located DocName
lname'    <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
    LHsQTyVars DocNameI
ltyvars'  <- LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
ltyvars
    [GenLocated SrcSpan ([Located DocName], [Located DocName])]
lfundeps' <- (GenLocated SrcSpan ([Located Name], [Located Name])
 -> RnM (GenLocated SrcSpan ([Located DocName], [Located DocName])))
-> [GenLocated SrcSpan ([Located Name], [Located Name])]
-> RnM [GenLocated SrcSpan ([Located DocName], [Located DocName])]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM GenLocated SrcSpan ([Located Name], [Located Name])
-> RnM (GenLocated SrcSpan ([Located DocName], [Located DocName]))
forall a a b b l.
(HasSrcSpan a, HasSrcSpan a, HasSrcSpan b, HasSrcSpan b,
 SrcSpanLess a ~ Name, SrcSpanLess b ~ DocName,
 SrcSpanLess b ~ DocName, SrcSpanLess a ~ Name) =>
GenLocated l ([a], [a]) -> RnM (GenLocated l ([b], [b]))
renameLFunDep [LHsFunDep GhcRn]
[GenLocated SrcSpan ([Located Name], [Located Name])]
lfundeps
    [GenLocated SrcSpan (Sig DocNameI)]
lsigs'    <- (LSig GhcRn -> RnM (GenLocated SrcSpan (Sig DocNameI)))
-> [LSig GhcRn] -> RnM [GenLocated SrcSpan (Sig DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LSig GhcRn -> RnM (GenLocated SrcSpan (Sig DocNameI))
forall l.
GenLocated l (Sig GhcRn) -> RnM (GenLocated l (Sig DocNameI))
renameLSig [LSig GhcRn]
lsigs
    [Located (FamilyDecl DocNameI)]
ats'      <- (LFamilyDecl GhcRn -> RnM (Located (FamilyDecl DocNameI)))
-> [LFamilyDecl GhcRn] -> RnM [Located (FamilyDecl DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI))
-> LFamilyDecl GhcRn -> RnM (Located (FamilyDecl DocNameI))
forall (a :: * -> *).
(a GhcRn -> RnM (a DocNameI))
-> Located (a GhcRn) -> RnM (Located (a DocNameI))
renameLThing FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI)
renameFamilyDecl) [LFamilyDecl GhcRn]
ats
    [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
at_defs'  <- (LTyFamDefltDecl GhcRn
 -> RnM (GenLocated SrcSpan (TyFamDefltDecl DocNameI)))
-> [LTyFamDefltDecl GhcRn]
-> RnM [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI))
-> LTyFamDefltDecl GhcRn
-> RnM (GenLocated SrcSpan (TyFamDefltDecl DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamDefltD) [LTyFamDefltDecl GhcRn]
at_defs
    -- we don't need the default methods or the already collected doc entities
    TyClDecl DocNameI -> RnM (TyClDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (ClassDecl :: forall pass.
XClassDecl pass
-> LHsContext pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> [LHsFunDep pass]
-> [LSig pass]
-> LHsBinds pass
-> [LFamilyDecl pass]
-> [LTyFamDefltDecl pass]
-> [LDocDecl]
-> TyClDecl pass
ClassDecl { tcdCtxt :: Located [LHsType DocNameI]
tcdCtxt = Located [LHsType DocNameI]
lcontext', tcdLName :: Located (IdP DocNameI)
tcdLName = Located (IdP DocNameI)
Located DocName
lname', tcdTyVars :: LHsQTyVars DocNameI
tcdTyVars = LHsQTyVars DocNameI
ltyvars'
                      , tcdFixity :: LexicalFixity
tcdFixity = LexicalFixity
fixity
                      , tcdFDs :: [LHsFunDep DocNameI]
tcdFDs = [LHsFunDep DocNameI]
[GenLocated SrcSpan ([Located DocName], [Located DocName])]
lfundeps', tcdSigs :: [GenLocated SrcSpan (Sig DocNameI)]
tcdSigs = [GenLocated SrcSpan (Sig DocNameI)]
lsigs', tcdMeths :: LHsBinds DocNameI
tcdMeths= LHsBinds DocNameI
forall a. Bag a
emptyBag
                      , tcdATs :: [Located (FamilyDecl DocNameI)]
tcdATs = [Located (FamilyDecl DocNameI)]
ats', tcdATDefs :: [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
tcdATDefs = [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
at_defs', tcdDocs :: [LDocDecl]
tcdDocs = [], tcdCExt :: XClassDecl DocNameI
tcdCExt = NoExtField
XClassDecl DocNameI
noExtField })
  XTyClDecl XXTyClDecl GhcRn
nec -> NoExtCon -> RnM (TyClDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXTyClDecl GhcRn
nec

  where
    renameLFunDep :: GenLocated l ([a], [a]) -> RnM (GenLocated l ([b], [b]))
renameLFunDep (L l
loc ([a]
xs, [a]
ys)) = do
      [DocName]
xs' <- (Name -> RnM DocName) -> [Name] -> RnM [DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Name -> RnM DocName
rename ((a -> Name) -> [a] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map a -> Name
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc [a]
xs)
      [DocName]
ys' <- (Name -> RnM DocName) -> [Name] -> RnM [DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Name -> RnM DocName
rename ((a -> Name) -> [a] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map a -> Name
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc [a]
ys)
      GenLocated l ([b], [b]) -> RnM (GenLocated l ([b], [b]))
forall (m :: * -> *) a. Monad m => a -> m a
return (l -> ([b], [b]) -> GenLocated l ([b], [b])
forall l e. l -> e -> GenLocated l e
L l
loc ((DocName -> b) -> [DocName] -> [b]
forall a b. (a -> b) -> [a] -> [b]
map DocName -> b
forall a. HasSrcSpan a => SrcSpanLess a -> a
noLoc [DocName]
xs', (DocName -> b) -> [DocName] -> [b]
forall a b. (a -> b) -> [a] -> [b]
map DocName -> b
forall a. HasSrcSpan a => SrcSpanLess a -> a
noLoc [DocName]
ys'))

    renameLSig :: GenLocated l (Sig GhcRn) -> RnM (GenLocated l (Sig DocNameI))
renameLSig (L l
loc Sig GhcRn
sig) = GenLocated l (Sig DocNameI) -> RnM (GenLocated l (Sig DocNameI))
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated l (Sig DocNameI) -> RnM (GenLocated l (Sig DocNameI)))
-> (Sig DocNameI -> GenLocated l (Sig DocNameI))
-> Sig DocNameI
-> RnM (GenLocated l (Sig DocNameI))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. l -> Sig DocNameI -> GenLocated l (Sig DocNameI)
forall l e. l -> e -> GenLocated l e
L l
loc (Sig DocNameI -> RnM (GenLocated l (Sig DocNameI)))
-> RnM (Sig DocNameI) -> RnM (GenLocated l (Sig DocNameI))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Sig GhcRn -> RnM (Sig DocNameI)
renameSig Sig GhcRn
sig

renameFamilyDecl :: FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI)
renameFamilyDecl :: FamilyDecl GhcRn -> RnM (FamilyDecl DocNameI)
renameFamilyDecl (FamilyDecl { fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdInfo = FamilyInfo GhcRn
info, fdLName :: forall pass. FamilyDecl pass -> Located (IdP pass)
fdLName = Located (IdP GhcRn)
lname
                             , fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdTyVars = LHsQTyVars GhcRn
ltyvars
                             , fdFixity :: forall pass. FamilyDecl pass -> LexicalFixity
fdFixity = LexicalFixity
fixity
                             , fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdResultSig = LFamilyResultSig GhcRn
result
                             , fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
fdInjectivityAnn = Maybe (LInjectivityAnn GhcRn)
injectivity }) = do
    FamilyInfo DocNameI
info'        <- FamilyInfo GhcRn -> RnM (FamilyInfo DocNameI)
renameFamilyInfo FamilyInfo GhcRn
info
    Located DocName
lname'       <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
    LHsQTyVars DocNameI
ltyvars'     <- LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
ltyvars
    LFamilyResultSig DocNameI
result'      <- LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)
renameFamilyResultSig LFamilyResultSig GhcRn
result
    Maybe (LInjectivityAnn DocNameI)
injectivity' <- Maybe (LInjectivityAnn GhcRn)
-> RnM (Maybe (LInjectivityAnn DocNameI))
renameMaybeInjectivityAnn Maybe (LInjectivityAnn GhcRn)
injectivity
    FamilyDecl DocNameI -> RnM (FamilyDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (FamilyDecl :: forall pass.
XCFamilyDecl pass
-> FamilyInfo pass
-> Located (IdP pass)
-> LHsQTyVars pass
-> LexicalFixity
-> LFamilyResultSig pass
-> Maybe (LInjectivityAnn pass)
-> FamilyDecl pass
FamilyDecl { fdExt :: XCFamilyDecl DocNameI
fdExt = NoExtField
XCFamilyDecl DocNameI
noExtField, fdInfo :: FamilyInfo DocNameI
fdInfo = FamilyInfo DocNameI
info', fdLName :: Located (IdP DocNameI)
fdLName = Located (IdP DocNameI)
Located DocName
lname'
                       , fdTyVars :: LHsQTyVars DocNameI
fdTyVars = LHsQTyVars DocNameI
ltyvars'
                       , fdFixity :: LexicalFixity
fdFixity = LexicalFixity
fixity
                       , fdResultSig :: LFamilyResultSig DocNameI
fdResultSig = LFamilyResultSig DocNameI
result'
                       , fdInjectivityAnn :: Maybe (LInjectivityAnn DocNameI)
fdInjectivityAnn = Maybe (LInjectivityAnn DocNameI)
injectivity' })
renameFamilyDecl (XFamilyDecl XXFamilyDecl GhcRn
nec) = NoExtCon -> RnM (FamilyDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXFamilyDecl GhcRn
nec


renamePseudoFamilyDecl :: PseudoFamilyDecl GhcRn
                       -> RnM (PseudoFamilyDecl DocNameI)
renamePseudoFamilyDecl :: PseudoFamilyDecl GhcRn -> RnM (PseudoFamilyDecl DocNameI)
renamePseudoFamilyDecl (PseudoFamilyDecl { [LHsType GhcRn]
FamilyInfo GhcRn
LFamilyResultSig GhcRn
Located (IdP GhcRn)
pfdKindSig :: forall name. PseudoFamilyDecl name -> LFamilyResultSig name
pfdTyVars :: forall name. PseudoFamilyDecl name -> [LHsType name]
pfdLName :: forall name. PseudoFamilyDecl name -> Located (IdP name)
pfdInfo :: forall name. PseudoFamilyDecl name -> FamilyInfo name
pfdKindSig :: LFamilyResultSig GhcRn
pfdTyVars :: [LHsType GhcRn]
pfdLName :: Located (IdP GhcRn)
pfdInfo :: FamilyInfo GhcRn
.. }) =  FamilyInfo DocNameI
-> Located DocName
-> [LHsType DocNameI]
-> LFamilyResultSig DocNameI
-> PseudoFamilyDecl DocNameI
forall name.
FamilyInfo name
-> Located (IdP name)
-> [LHsType name]
-> LFamilyResultSig name
-> PseudoFamilyDecl name
PseudoFamilyDecl
    (FamilyInfo DocNameI
 -> Located DocName
 -> [LHsType DocNameI]
 -> LFamilyResultSig DocNameI
 -> PseudoFamilyDecl DocNameI)
-> RnM (FamilyInfo DocNameI)
-> RnM
     (Located DocName
      -> [LHsType DocNameI]
      -> LFamilyResultSig DocNameI
      -> PseudoFamilyDecl DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FamilyInfo GhcRn -> RnM (FamilyInfo DocNameI)
renameFamilyInfo FamilyInfo GhcRn
pfdInfo
    RnM
  (Located DocName
   -> [LHsType DocNameI]
   -> LFamilyResultSig DocNameI
   -> PseudoFamilyDecl DocNameI)
-> RnM (Located DocName)
-> RnM
     ([LHsType DocNameI]
      -> LFamilyResultSig DocNameI -> PseudoFamilyDecl DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
pfdLName
    RnM
  ([LHsType DocNameI]
   -> LFamilyResultSig DocNameI -> PseudoFamilyDecl DocNameI)
-> RnM [LHsType DocNameI]
-> RnM (LFamilyResultSig DocNameI -> PseudoFamilyDecl DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
pfdTyVars
    RnM (LFamilyResultSig DocNameI -> PseudoFamilyDecl DocNameI)
-> RnM (LFamilyResultSig DocNameI)
-> RnM (PseudoFamilyDecl DocNameI)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LFamilyResultSig GhcRn -> RnM (LFamilyResultSig DocNameI)
renameFamilyResultSig LFamilyResultSig GhcRn
pfdKindSig


renameFamilyInfo :: FamilyInfo GhcRn -> RnM (FamilyInfo DocNameI)
renameFamilyInfo :: FamilyInfo GhcRn -> RnM (FamilyInfo DocNameI)
renameFamilyInfo FamilyInfo GhcRn
DataFamily     = FamilyInfo DocNameI -> RnM (FamilyInfo DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return FamilyInfo DocNameI
forall pass. FamilyInfo pass
DataFamily
renameFamilyInfo FamilyInfo GhcRn
OpenTypeFamily = FamilyInfo DocNameI -> RnM (FamilyInfo DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return FamilyInfo DocNameI
forall pass. FamilyInfo pass
OpenTypeFamily
renameFamilyInfo (ClosedTypeFamily Maybe [LTyFamInstEqn GhcRn]
eqns)
  = do { Maybe [GenLocated SrcSpan (TyFamInstEqn DocNameI)]
eqns' <- ([LTyFamInstEqn GhcRn]
 -> RnM [GenLocated SrcSpan (TyFamInstEqn DocNameI)])
-> Maybe [LTyFamInstEqn GhcRn]
-> RnM (Maybe [GenLocated SrcSpan (TyFamInstEqn DocNameI)])
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((LTyFamInstEqn GhcRn
 -> RnM (GenLocated SrcSpan (TyFamInstEqn DocNameI)))
-> [LTyFamInstEqn GhcRn]
-> RnM [GenLocated SrcSpan (TyFamInstEqn DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI))
-> LTyFamInstEqn GhcRn
-> RnM (GenLocated SrcSpan (TyFamInstEqn DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
renameTyFamInstEqn)) Maybe [LTyFamInstEqn GhcRn]
eqns
       ; FamilyInfo DocNameI -> RnM (FamilyInfo DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (FamilyInfo DocNameI -> RnM (FamilyInfo DocNameI))
-> FamilyInfo DocNameI -> RnM (FamilyInfo DocNameI)
forall a b. (a -> b) -> a -> b
$ Maybe [GenLocated SrcSpan (TyFamInstEqn DocNameI)]
-> FamilyInfo DocNameI
forall pass. Maybe [LTyFamInstEqn pass] -> FamilyInfo pass
ClosedTypeFamily Maybe [GenLocated SrcSpan (TyFamInstEqn DocNameI)]
eqns' }

renameDataDefn :: HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)
renameDataDefn :: HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)
renameDataDefn (HsDataDefn { dd_ND :: forall pass. HsDataDefn pass -> NewOrData
dd_ND = NewOrData
nd, dd_ctxt :: forall pass. HsDataDefn pass -> LHsContext pass
dd_ctxt = LHsContext GhcRn
lcontext, dd_cType :: forall pass. HsDataDefn pass -> Maybe (Located CType)
dd_cType = Maybe (Located CType)
cType
                           , dd_kindSig :: forall pass. HsDataDefn pass -> Maybe (LHsKind pass)
dd_kindSig = Maybe (LHsType GhcRn)
k, dd_cons :: forall pass. HsDataDefn pass -> [LConDecl pass]
dd_cons = [LConDecl GhcRn]
cons }) = do
    Located [LHsType DocNameI]
lcontext' <- LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext LHsContext GhcRn
lcontext
    Maybe (LHsType DocNameI)
k'        <- Maybe (LHsType GhcRn) -> RnM (Maybe (LHsType DocNameI))
renameMaybeLKind Maybe (LHsType GhcRn)
k
    [GenLocated SrcSpan (ConDecl DocNameI)]
cons'     <- (LConDecl GhcRn -> RnM (GenLocated SrcSpan (ConDecl DocNameI)))
-> [LConDecl GhcRn] -> RnM [GenLocated SrcSpan (ConDecl DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ConDecl GhcRn -> RnM (ConDecl DocNameI))
-> LConDecl GhcRn -> RnM (GenLocated SrcSpan (ConDecl DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ConDecl GhcRn -> RnM (ConDecl DocNameI)
renameCon) [LConDecl GhcRn]
cons
    -- I don't think we need the derivings, so we return Nothing
    HsDataDefn DocNameI -> RnM (HsDataDefn DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsDataDefn :: forall pass.
XCHsDataDefn pass
-> NewOrData
-> LHsContext pass
-> Maybe (Located CType)
-> Maybe (LHsKind pass)
-> [LConDecl pass]
-> HsDeriving pass
-> HsDataDefn pass
HsDataDefn { dd_ext :: XCHsDataDefn DocNameI
dd_ext = NoExtField
XCHsDataDefn DocNameI
noExtField
                       , dd_ND :: NewOrData
dd_ND = NewOrData
nd, dd_ctxt :: Located [LHsType DocNameI]
dd_ctxt = Located [LHsType DocNameI]
lcontext', dd_cType :: Maybe (Located CType)
dd_cType = Maybe (Located CType)
cType
                       , dd_kindSig :: Maybe (LHsType DocNameI)
dd_kindSig = Maybe (LHsType DocNameI)
k', dd_cons :: [GenLocated SrcSpan (ConDecl DocNameI)]
dd_cons = [GenLocated SrcSpan (ConDecl DocNameI)]
cons'
                       , dd_derivs :: HsDeriving DocNameI
dd_derivs = SrcSpanLess (HsDeriving DocNameI) -> HsDeriving DocNameI
forall a. HasSrcSpan a => SrcSpanLess a -> a
noLoc [] })
renameDataDefn (XHsDataDefn XXHsDataDefn GhcRn
nec) = NoExtCon -> RnM (HsDataDefn DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXHsDataDefn GhcRn
nec

renameCon :: ConDecl GhcRn -> RnM (ConDecl DocNameI)
renameCon :: ConDecl GhcRn -> RnM (ConDecl DocNameI)
renameCon decl :: ConDecl GhcRn
decl@(ConDeclH98 { con_name :: forall pass. ConDecl pass -> Located (IdP pass)
con_name = Located (IdP GhcRn)
lname, con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr pass]
con_ex_tvs = [LHsTyVarBndr GhcRn]
ltyvars
                           , con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcRn)
lcontext, con_args :: forall pass. ConDecl pass -> HsConDeclDetails pass
con_args = HsConDeclDetails GhcRn
details
                           , con_doc :: forall pass. ConDecl pass -> Maybe LHsDocString
con_doc = Maybe LHsDocString
mbldoc }) = do
      Located DocName
lname'    <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
      [LHsTyVarBndr DocNameI]
ltyvars'  <- (LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI))
-> [LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr [LHsTyVarBndr GhcRn]
ltyvars
      Maybe (Located [LHsType DocNameI])
lcontext' <- (LHsContext GhcRn -> RnM (Located [LHsType DocNameI]))
-> Maybe (LHsContext GhcRn)
-> RnM (Maybe (Located [LHsType DocNameI]))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext Maybe (LHsContext GhcRn)
lcontext
      HsConDeclDetails DocNameI
details'  <- HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI)
renameDetails HsConDeclDetails GhcRn
details
      Maybe LHsDocString
mbldoc'   <- (LHsDocString -> RnM LHsDocString)
-> Maybe LHsDocString -> RnM (Maybe LHsDocString)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsDocString -> RnM LHsDocString
renameLDocHsSyn Maybe LHsDocString
mbldoc
      ConDecl DocNameI -> RnM (ConDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (ConDecl GhcRn
decl { con_ext :: XConDeclH98 DocNameI
con_ext = NoExtField
XConDeclH98 DocNameI
noExtField, con_name :: Located (IdP DocNameI)
con_name = Located (IdP DocNameI)
Located DocName
lname', con_ex_tvs :: [LHsTyVarBndr DocNameI]
con_ex_tvs = [LHsTyVarBndr DocNameI]
ltyvars'
                   , con_mb_cxt :: Maybe (Located [LHsType DocNameI])
con_mb_cxt = Maybe (Located [LHsType DocNameI])
lcontext'
                   , con_args :: HsConDeclDetails DocNameI
con_args = HsConDeclDetails DocNameI
details', con_doc :: Maybe LHsDocString
con_doc = Maybe LHsDocString
mbldoc' })

renameCon decl :: ConDecl GhcRn
decl@(ConDeclGADT { con_names :: forall pass. ConDecl pass -> [Located (IdP pass)]
con_names = [Located (IdP GhcRn)]
lnames, con_qvars :: forall pass. ConDecl pass -> LHsQTyVars pass
con_qvars = LHsQTyVars GhcRn
ltyvars
                            , con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_mb_cxt = Maybe (LHsContext GhcRn)
lcontext, con_args :: forall pass. ConDecl pass -> HsConDeclDetails pass
con_args = HsConDeclDetails GhcRn
details
                            , con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_res_ty = LHsType GhcRn
res_ty
                            , con_doc :: forall pass. ConDecl pass -> Maybe LHsDocString
con_doc = Maybe LHsDocString
mbldoc }) = do
      [Located DocName]
lnames'   <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
lnames
      LHsQTyVars DocNameI
ltyvars'  <- LHsQTyVars GhcRn -> RnM (LHsQTyVars DocNameI)
renameLHsQTyVars LHsQTyVars GhcRn
ltyvars
      Maybe (Located [LHsType DocNameI])
lcontext' <- (LHsContext GhcRn -> RnM (Located [LHsType DocNameI]))
-> Maybe (LHsContext GhcRn)
-> RnM (Maybe (Located [LHsType DocNameI]))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse LHsContext GhcRn -> RnM (Located [LHsType DocNameI])
renameLContext Maybe (LHsContext GhcRn)
lcontext
      HsConDeclDetails DocNameI
details'  <- HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI)
renameDetails HsConDeclDetails GhcRn
details
      LHsType DocNameI
res_ty'   <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
res_ty
      Maybe LHsDocString
mbldoc'   <- (LHsDocString -> RnM LHsDocString)
-> Maybe LHsDocString -> RnM (Maybe LHsDocString)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsDocString -> RnM LHsDocString
renameLDocHsSyn Maybe LHsDocString
mbldoc
      ConDecl DocNameI -> RnM (ConDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (ConDecl GhcRn
decl { con_g_ext :: XConDeclGADT DocNameI
con_g_ext = NoExtField
XConDeclGADT DocNameI
noExtField, con_names :: [Located (IdP DocNameI)]
con_names = [Located (IdP DocNameI)]
[Located DocName]
lnames', con_qvars :: LHsQTyVars DocNameI
con_qvars = LHsQTyVars DocNameI
ltyvars'
                   , con_mb_cxt :: Maybe (Located [LHsType DocNameI])
con_mb_cxt = Maybe (Located [LHsType DocNameI])
lcontext', con_args :: HsConDeclDetails DocNameI
con_args = HsConDeclDetails DocNameI
details'
                   , con_res_ty :: LHsType DocNameI
con_res_ty = LHsType DocNameI
res_ty', con_doc :: Maybe LHsDocString
con_doc = Maybe LHsDocString
mbldoc' })
renameCon (XConDecl XXConDecl GhcRn
nec) = NoExtCon -> RnM (ConDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXConDecl GhcRn
nec

renameDetails :: HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI)
renameDetails :: HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI)
renameDetails (RecCon (L SrcSpan
l [LConDeclField GhcRn]
fields)) = do
  [LConDeclField DocNameI]
fields' <- (LConDeclField GhcRn -> RnM (LConDeclField DocNameI))
-> [LConDeclField GhcRn] -> RnM [LConDeclField DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LConDeclField GhcRn -> RnM (LConDeclField DocNameI)
renameConDeclFieldField [LConDeclField GhcRn]
fields
  HsConDeclDetails DocNameI -> RnM (HsConDeclDetails DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (GenLocated SrcSpan [LConDeclField DocNameI]
-> HsConDeclDetails DocNameI
forall arg rec. rec -> HsConDetails arg rec
RecCon (SrcSpan
-> [LConDeclField DocNameI]
-> GenLocated SrcSpan [LConDeclField DocNameI]
forall l e. l -> e -> GenLocated l e
L SrcSpan
l [LConDeclField DocNameI]
fields'))
renameDetails (PrefixCon [LHsType GhcRn]
ps) = HsConDeclDetails DocNameI -> RnM (HsConDeclDetails DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsConDeclDetails DocNameI -> RnM (HsConDeclDetails DocNameI))
-> ([LHsType DocNameI] -> HsConDeclDetails DocNameI)
-> [LHsType DocNameI]
-> RnM (HsConDeclDetails DocNameI)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [LHsType DocNameI] -> HsConDeclDetails DocNameI
forall arg rec. [arg] -> HsConDetails arg rec
PrefixCon ([LHsType DocNameI] -> RnM (HsConDeclDetails DocNameI))
-> RnM [LHsType DocNameI] -> RnM (HsConDeclDetails DocNameI)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (LHsType GhcRn -> RnM (LHsType DocNameI))
-> [LHsType GhcRn] -> RnM [LHsType DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType [LHsType GhcRn]
ps
renameDetails (InfixCon LHsType GhcRn
a LHsType GhcRn
b) = do
  LHsType DocNameI
a' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
a
  LHsType DocNameI
b' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
b
  HsConDeclDetails DocNameI -> RnM (HsConDeclDetails DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsType DocNameI -> LHsType DocNameI -> HsConDeclDetails DocNameI
forall arg rec. arg -> arg -> HsConDetails arg rec
InfixCon LHsType DocNameI
a' LHsType DocNameI
b')

renameConDeclFieldField :: LConDeclField GhcRn -> RnM (LConDeclField DocNameI)
renameConDeclFieldField :: LConDeclField GhcRn -> RnM (LConDeclField DocNameI)
renameConDeclFieldField (L SrcSpan
l (ConDeclField XConDeclField GhcRn
_ [LFieldOcc GhcRn]
names LHsType GhcRn
t Maybe LHsDocString
doc)) = do
  [LFieldOcc DocNameI]
names' <- (LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI))
-> [LFieldOcc GhcRn] -> RnM [LFieldOcc DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI)
renameLFieldOcc [LFieldOcc GhcRn]
names
  LHsType DocNameI
t'   <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
t
  Maybe LHsDocString
doc' <- (LHsDocString -> RnM LHsDocString)
-> Maybe LHsDocString -> RnM (Maybe LHsDocString)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsDocString -> RnM LHsDocString
renameLDocHsSyn Maybe LHsDocString
doc
  LConDeclField DocNameI -> RnM (LConDeclField DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LConDeclField DocNameI -> RnM (LConDeclField DocNameI))
-> LConDeclField DocNameI -> RnM (LConDeclField DocNameI)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> ConDeclField DocNameI -> LConDeclField DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
l (XConDeclField DocNameI
-> [LFieldOcc DocNameI]
-> LHsType DocNameI
-> Maybe LHsDocString
-> ConDeclField DocNameI
forall pass.
XConDeclField pass
-> [LFieldOcc pass]
-> LBangType pass
-> Maybe LHsDocString
-> ConDeclField pass
ConDeclField NoExtField
XConDeclField DocNameI
noExtField [LFieldOcc DocNameI]
names' LHsType DocNameI
t' Maybe LHsDocString
doc')
renameConDeclFieldField (L SrcSpan
_ (XConDeclField XXConDeclField GhcRn
nec)) = NoExtCon -> RnM (LConDeclField DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXConDeclField GhcRn
nec

renameLFieldOcc :: LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI)
renameLFieldOcc :: LFieldOcc GhcRn -> RnM (LFieldOcc DocNameI)
renameLFieldOcc (L SrcSpan
l (FieldOcc XCFieldOcc GhcRn
sel Located RdrName
lbl)) = do
  DocName
sel' <- Name -> RnM DocName
rename XCFieldOcc GhcRn
Name
sel
  LFieldOcc DocNameI -> RnM (LFieldOcc DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LFieldOcc DocNameI -> RnM (LFieldOcc DocNameI))
-> LFieldOcc DocNameI -> RnM (LFieldOcc DocNameI)
forall a b. (a -> b) -> a -> b
$ SrcSpan -> FieldOcc DocNameI -> LFieldOcc DocNameI
forall l e. l -> e -> GenLocated l e
L SrcSpan
l (XCFieldOcc DocNameI -> Located RdrName -> FieldOcc DocNameI
forall pass. XCFieldOcc pass -> Located RdrName -> FieldOcc pass
FieldOcc XCFieldOcc DocNameI
DocName
sel' Located RdrName
lbl)
renameLFieldOcc (L SrcSpan
_ (XFieldOcc XXFieldOcc GhcRn
nec)) = NoExtCon -> RnM (LFieldOcc DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXFieldOcc GhcRn
nec

renameSig :: Sig GhcRn -> RnM (Sig DocNameI)
renameSig :: Sig GhcRn -> RnM (Sig DocNameI)
renameSig Sig GhcRn
sig = case Sig GhcRn
sig of
  TypeSig XTypeSig GhcRn
_ [Located (IdP GhcRn)]
lnames LHsSigWcType GhcRn
ltype -> do
    [Located DocName]
lnames' <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
lnames
    LHsSigWcType DocNameI
ltype' <- LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
renameLSigWcType LHsSigWcType GhcRn
ltype
    Sig DocNameI -> RnM (Sig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XTypeSig DocNameI
-> [Located (IdP DocNameI)]
-> LHsSigWcType DocNameI
-> Sig DocNameI
forall pass.
XTypeSig pass
-> [Located (IdP pass)] -> LHsSigWcType pass -> Sig pass
TypeSig NoExtField
XTypeSig DocNameI
noExtField [Located (IdP DocNameI)]
[Located DocName]
lnames' LHsSigWcType DocNameI
ltype')
  ClassOpSig XClassOpSig GhcRn
_ Bool
is_default [Located (IdP GhcRn)]
lnames LHsSigType GhcRn
sig_ty -> do
    [Located DocName]
lnames' <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
lnames
    LHsSigType DocNameI
ltype' <- LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
sig_ty
    Sig DocNameI -> RnM (Sig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XClassOpSig DocNameI
-> Bool
-> [Located (IdP DocNameI)]
-> LHsSigType DocNameI
-> Sig DocNameI
forall pass.
XClassOpSig pass
-> Bool -> [Located (IdP pass)] -> LHsSigType pass -> Sig pass
ClassOpSig NoExtField
XClassOpSig DocNameI
noExtField Bool
is_default [Located (IdP DocNameI)]
[Located DocName]
lnames' LHsSigType DocNameI
ltype')
  PatSynSig XPatSynSig GhcRn
_ [Located (IdP GhcRn)]
lnames LHsSigType GhcRn
sig_ty -> do
    [Located DocName]
lnames' <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
lnames
    LHsSigType DocNameI
sig_ty' <- LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
sig_ty
    Sig DocNameI -> RnM (Sig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig DocNameI -> RnM (Sig DocNameI))
-> Sig DocNameI -> RnM (Sig DocNameI)
forall a b. (a -> b) -> a -> b
$ XPatSynSig DocNameI
-> [Located (IdP DocNameI)] -> LHsSigType DocNameI -> Sig DocNameI
forall pass.
XPatSynSig pass
-> [Located (IdP pass)] -> LHsSigType pass -> Sig pass
PatSynSig NoExtField
XPatSynSig DocNameI
noExtField [Located (IdP DocNameI)]
[Located DocName]
lnames' LHsSigType DocNameI
sig_ty'
  FixSig XFixSig GhcRn
_ (FixitySig XFixitySig GhcRn
_ [Located (IdP GhcRn)]
lnames Fixity
fixity) -> do
    [Located DocName]
lnames' <- (Located Name -> RnM (Located DocName))
-> [Located Name] -> RnM [Located DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Located Name -> RnM (Located DocName)
renameL [Located (IdP GhcRn)]
[Located Name]
lnames
    Sig DocNameI -> RnM (Sig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig DocNameI -> RnM (Sig DocNameI))
-> Sig DocNameI -> RnM (Sig DocNameI)
forall a b. (a -> b) -> a -> b
$ XFixSig DocNameI -> FixitySig DocNameI -> Sig DocNameI
forall pass. XFixSig pass -> FixitySig pass -> Sig pass
FixSig NoExtField
XFixSig DocNameI
noExtField (XFixitySig DocNameI
-> [Located (IdP DocNameI)] -> Fixity -> FixitySig DocNameI
forall pass.
XFixitySig pass -> [Located (IdP pass)] -> Fixity -> FixitySig pass
FixitySig NoExtField
XFixitySig DocNameI
noExtField [Located (IdP DocNameI)]
[Located DocName]
lnames' Fixity
fixity)
  MinimalSig XMinimalSig GhcRn
_ SourceText
src (L SrcSpan
l BooleanFormula (Located (IdP GhcRn))
s) -> do
    BooleanFormula (Located DocName)
s' <- (Located Name -> RnM (Located DocName))
-> BooleanFormula (Located Name)
-> RnM (BooleanFormula (Located DocName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((Name -> RnM DocName) -> Located Name -> RnM (Located DocName)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Name -> RnM DocName
lookupRnNoWarn) BooleanFormula (Located (IdP GhcRn))
BooleanFormula (Located Name)
s
    Sig DocNameI -> RnM (Sig DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig DocNameI -> RnM (Sig DocNameI))
-> Sig DocNameI -> RnM (Sig DocNameI)
forall a b. (a -> b) -> a -> b
$ XMinimalSig DocNameI
-> SourceText
-> LBooleanFormula (Located (IdP DocNameI))
-> Sig DocNameI
forall pass.
XMinimalSig pass
-> SourceText -> LBooleanFormula (Located (IdP pass)) -> Sig pass
MinimalSig NoExtField
XMinimalSig DocNameI
noExtField SourceText
src (SrcSpan
-> BooleanFormula (Located DocName)
-> GenLocated SrcSpan (BooleanFormula (Located DocName))
forall l e. l -> e -> GenLocated l e
L SrcSpan
l BooleanFormula (Located DocName)
s')
  -- we have filtered out all other kinds of signatures in Interface.Create
  Sig GhcRn
_ -> String -> RnM (Sig DocNameI)
forall a. HasCallStack => String -> a
error String
"expected TypeSig"


renameForD :: ForeignDecl GhcRn -> RnM (ForeignDecl DocNameI)
renameForD :: ForeignDecl GhcRn -> RnM (ForeignDecl DocNameI)
renameForD (ForeignImport XForeignImport GhcRn
_ Located (IdP GhcRn)
lname LHsSigType GhcRn
ltype ForeignImport
x) = do
  Located DocName
lname' <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
  LHsSigType DocNameI
ltype' <- LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
ltype
  ForeignDecl DocNameI -> RnM (ForeignDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XForeignImport DocNameI
-> Located (IdP DocNameI)
-> LHsSigType DocNameI
-> ForeignImport
-> ForeignDecl DocNameI
forall pass.
XForeignImport pass
-> Located (IdP pass)
-> LHsSigType pass
-> ForeignImport
-> ForeignDecl pass
ForeignImport NoExtField
XForeignImport DocNameI
noExtField Located (IdP DocNameI)
Located DocName
lname' LHsSigType DocNameI
ltype' ForeignImport
x)
renameForD (ForeignExport XForeignExport GhcRn
_ Located (IdP GhcRn)
lname LHsSigType GhcRn
ltype ForeignExport
x) = do
  Located DocName
lname' <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
lname
  LHsSigType DocNameI
ltype' <- LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
ltype
  ForeignDecl DocNameI -> RnM (ForeignDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (XForeignExport DocNameI
-> Located (IdP DocNameI)
-> LHsSigType DocNameI
-> ForeignExport
-> ForeignDecl DocNameI
forall pass.
XForeignExport pass
-> Located (IdP pass)
-> LHsSigType pass
-> ForeignExport
-> ForeignDecl pass
ForeignExport NoExtField
XForeignExport DocNameI
noExtField Located (IdP DocNameI)
Located DocName
lname' LHsSigType DocNameI
ltype' ForeignExport
x)
renameForD (XForeignDecl XXForeignDecl GhcRn
nec) = NoExtCon -> RnM (ForeignDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXForeignDecl GhcRn
nec


renameInstD :: InstDecl GhcRn -> RnM (InstDecl DocNameI)
renameInstD :: InstDecl GhcRn -> RnM (InstDecl DocNameI)
renameInstD (ClsInstD { cid_inst :: forall pass. InstDecl pass -> ClsInstDecl pass
cid_inst = ClsInstDecl GhcRn
d }) = do
  ClsInstDecl DocNameI
d' <- ClsInstDecl GhcRn -> RnM (ClsInstDecl DocNameI)
renameClsInstD ClsInstDecl GhcRn
d
  InstDecl DocNameI -> RnM (InstDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (ClsInstD :: forall pass. XClsInstD pass -> ClsInstDecl pass -> InstDecl pass
ClsInstD { cid_d_ext :: XClsInstD DocNameI
cid_d_ext = NoExtField
XClsInstD DocNameI
noExtField, cid_inst :: ClsInstDecl DocNameI
cid_inst = ClsInstDecl DocNameI
d' })
renameInstD (TyFamInstD { tfid_inst :: forall pass. InstDecl pass -> TyFamInstDecl pass
tfid_inst = TyFamDefltDecl GhcRn
d }) = do
  TyFamDefltDecl DocNameI
d' <- TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamInstD TyFamDefltDecl GhcRn
d
  InstDecl DocNameI -> RnM (InstDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (TyFamInstD :: forall pass.
XTyFamInstD pass -> TyFamInstDecl pass -> InstDecl pass
TyFamInstD { tfid_ext :: XTyFamInstD DocNameI
tfid_ext = NoExtField
XTyFamInstD DocNameI
noExtField, tfid_inst :: TyFamDefltDecl DocNameI
tfid_inst = TyFamDefltDecl DocNameI
d' })
renameInstD (DataFamInstD { dfid_inst :: forall pass. InstDecl pass -> DataFamInstDecl pass
dfid_inst = DataFamInstDecl GhcRn
d }) = do
  DataFamInstDecl DocNameI
d' <- DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI)
renameDataFamInstD DataFamInstDecl GhcRn
d
  InstDecl DocNameI -> RnM (InstDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (DataFamInstD :: forall pass.
XDataFamInstD pass -> DataFamInstDecl pass -> InstDecl pass
DataFamInstD { dfid_ext :: XDataFamInstD DocNameI
dfid_ext = NoExtField
XDataFamInstD DocNameI
noExtField, dfid_inst :: DataFamInstDecl DocNameI
dfid_inst = DataFamInstDecl DocNameI
d' })
renameInstD (XInstDecl XXInstDecl GhcRn
nec) = NoExtCon -> RnM (InstDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXInstDecl GhcRn
nec

renameDerivD :: DerivDecl GhcRn -> RnM (DerivDecl DocNameI)
renameDerivD :: DerivDecl GhcRn -> RnM (DerivDecl DocNameI)
renameDerivD (DerivDecl { deriv_type :: forall pass. DerivDecl pass -> LHsSigWcType pass
deriv_type = LHsSigWcType GhcRn
ty
                        , deriv_strategy :: forall pass. DerivDecl pass -> Maybe (LDerivStrategy pass)
deriv_strategy = Maybe (LDerivStrategy GhcRn)
strat
                        , deriv_overlap_mode :: forall pass. DerivDecl pass -> Maybe (Located OverlapMode)
deriv_overlap_mode = Maybe (Located OverlapMode)
omode }) = do
  LHsSigWcType DocNameI
ty'    <- LHsSigWcType GhcRn -> RnM (LHsSigWcType DocNameI)
renameLSigWcType LHsSigWcType GhcRn
ty
  Maybe (GenLocated SrcSpan (DerivStrategy DocNameI))
strat' <- (LDerivStrategy GhcRn
 -> RnM (GenLocated SrcSpan (DerivStrategy DocNameI)))
-> Maybe (LDerivStrategy GhcRn)
-> RnM (Maybe (GenLocated SrcSpan (DerivStrategy DocNameI)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI))
-> LDerivStrategy GhcRn
-> RnM (GenLocated SrcSpan (DerivStrategy DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)
renameDerivStrategy) Maybe (LDerivStrategy GhcRn)
strat
  DerivDecl DocNameI -> RnM (DerivDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (DerivDecl :: forall pass.
XCDerivDecl pass
-> LHsSigWcType pass
-> Maybe (LDerivStrategy pass)
-> Maybe (Located OverlapMode)
-> DerivDecl pass
DerivDecl { deriv_ext :: XCDerivDecl DocNameI
deriv_ext = NoExtField
XCDerivDecl DocNameI
noExtField
                    , deriv_type :: LHsSigWcType DocNameI
deriv_type = LHsSigWcType DocNameI
ty'
                    , deriv_strategy :: Maybe (GenLocated SrcSpan (DerivStrategy DocNameI))
deriv_strategy = Maybe (GenLocated SrcSpan (DerivStrategy DocNameI))
strat'
                    , deriv_overlap_mode :: Maybe (Located OverlapMode)
deriv_overlap_mode = Maybe (Located OverlapMode)
omode })
renameDerivD (XDerivDecl XXDerivDecl GhcRn
nec) = NoExtCon -> RnM (DerivDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXDerivDecl GhcRn
nec

renameDerivStrategy :: DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)
renameDerivStrategy :: DerivStrategy GhcRn -> RnM (DerivStrategy DocNameI)
renameDerivStrategy DerivStrategy GhcRn
StockStrategy    = DerivStrategy DocNameI -> RnM (DerivStrategy DocNameI)
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy DocNameI
forall pass. DerivStrategy pass
StockStrategy
renameDerivStrategy DerivStrategy GhcRn
AnyclassStrategy = DerivStrategy DocNameI -> RnM (DerivStrategy DocNameI)
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy DocNameI
forall pass. DerivStrategy pass
AnyclassStrategy
renameDerivStrategy DerivStrategy GhcRn
NewtypeStrategy  = DerivStrategy DocNameI -> RnM (DerivStrategy DocNameI)
forall (f :: * -> *) a. Applicative f => a -> f a
pure DerivStrategy DocNameI
forall pass. DerivStrategy pass
NewtypeStrategy
renameDerivStrategy (ViaStrategy XViaStrategy GhcRn
ty) = LHsSigType DocNameI -> DerivStrategy DocNameI
forall pass. XViaStrategy pass -> DerivStrategy pass
ViaStrategy (LHsSigType DocNameI -> DerivStrategy DocNameI)
-> RnM (LHsSigType DocNameI) -> RnM (DerivStrategy DocNameI)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
XViaStrategy GhcRn
ty

renameClsInstD :: ClsInstDecl GhcRn -> RnM (ClsInstDecl DocNameI)
renameClsInstD :: ClsInstDecl GhcRn -> RnM (ClsInstDecl DocNameI)
renameClsInstD (ClsInstDecl { cid_overlap_mode :: forall pass. ClsInstDecl pass -> Maybe (Located OverlapMode)
cid_overlap_mode = Maybe (Located OverlapMode)
omode
                            , cid_poly_ty :: forall pass. ClsInstDecl pass -> LHsSigType pass
cid_poly_ty =LHsSigType GhcRn
ltype, cid_tyfam_insts :: forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_tyfam_insts = [LTyFamDefltDecl GhcRn]
lATs
                            , cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_datafam_insts = [LDataFamInstDecl GhcRn]
lADTs }) = do
  LHsSigType DocNameI
ltype' <- LHsSigType GhcRn -> RnM (LHsSigType DocNameI)
renameLSigType LHsSigType GhcRn
ltype
  [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
lATs'  <- (LTyFamDefltDecl GhcRn
 -> RnM (GenLocated SrcSpan (TyFamDefltDecl DocNameI)))
-> [LTyFamDefltDecl GhcRn]
-> RnM [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI))
-> LTyFamDefltDecl GhcRn
-> RnM (GenLocated SrcSpan (TyFamDefltDecl DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamInstD) [LTyFamDefltDecl GhcRn]
lATs
  [GenLocated SrcSpan (DataFamInstDecl DocNameI)]
lADTs' <- (LDataFamInstDecl GhcRn
 -> RnM (GenLocated SrcSpan (DataFamInstDecl DocNameI)))
-> [LDataFamInstDecl GhcRn]
-> RnM [GenLocated SrcSpan (DataFamInstDecl DocNameI)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI))
-> LDataFamInstDecl GhcRn
-> RnM (GenLocated SrcSpan (DataFamInstDecl DocNameI))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI)
renameDataFamInstD) [LDataFamInstDecl GhcRn]
lADTs
  ClsInstDecl DocNameI -> RnM (ClsInstDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (ClsInstDecl :: forall pass.
XCClsInstDecl pass
-> LHsSigType pass
-> LHsBinds pass
-> [LSig pass]
-> [LTyFamInstDecl pass]
-> [LDataFamInstDecl pass]
-> Maybe (Located OverlapMode)
-> ClsInstDecl pass
ClsInstDecl { cid_ext :: XCClsInstDecl DocNameI
cid_ext = NoExtField
XCClsInstDecl DocNameI
noExtField, cid_overlap_mode :: Maybe (Located OverlapMode)
cid_overlap_mode = Maybe (Located OverlapMode)
omode
                      , cid_poly_ty :: LHsSigType DocNameI
cid_poly_ty = LHsSigType DocNameI
ltype', cid_binds :: LHsBinds DocNameI
cid_binds = LHsBinds DocNameI
forall a. Bag a
emptyBag
                      , cid_sigs :: [GenLocated SrcSpan (Sig DocNameI)]
cid_sigs = []
                      , cid_tyfam_insts :: [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
cid_tyfam_insts = [GenLocated SrcSpan (TyFamDefltDecl DocNameI)]
lATs', cid_datafam_insts :: [GenLocated SrcSpan (DataFamInstDecl DocNameI)]
cid_datafam_insts = [GenLocated SrcSpan (DataFamInstDecl DocNameI)]
lADTs' })
renameClsInstD (XClsInstDecl XXClsInstDecl GhcRn
nec) = NoExtCon -> RnM (ClsInstDecl DocNameI)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXClsInstDecl GhcRn
nec


renameTyFamInstD :: TyFamInstDecl GhcRn -> RnM (TyFamInstDecl DocNameI)
renameTyFamInstD :: TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamInstD (TyFamInstDecl { tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
tfid_eqn = TyFamInstEqn GhcRn
eqn })
  = do { TyFamInstEqn DocNameI
eqn' <- TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
renameTyFamInstEqn TyFamInstEqn GhcRn
eqn
       ; TyFamDefltDecl DocNameI -> RnM (TyFamDefltDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (TyFamInstDecl :: forall pass. TyFamInstEqn pass -> TyFamInstDecl pass
TyFamInstDecl { tfid_eqn :: TyFamInstEqn DocNameI
tfid_eqn = TyFamInstEqn DocNameI
eqn' }) }

renameTyFamInstEqn :: TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
renameTyFamInstEqn :: TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
renameTyFamInstEqn TyFamInstEqn GhcRn
eqn
  = (FamEqn GhcRn (LHsType GhcRn)
 -> RnM (FamEqn DocNameI (LHsType DocNameI)))
-> TyFamInstEqn GhcRn -> RnM (TyFamInstEqn DocNameI)
forall in_thing out_thing.
(in_thing -> RnM out_thing)
-> HsImplicitBndrs GhcRn in_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit FamEqn GhcRn (LHsType GhcRn)
-> RnM (FamEqn DocNameI (LHsType DocNameI))
rename_ty_fam_eqn TyFamInstEqn GhcRn
eqn
  where
    rename_ty_fam_eqn
      :: FamEqn GhcRn (LHsType GhcRn)
      -> RnM (FamEqn DocNameI (LHsType DocNameI))
    rename_ty_fam_eqn :: FamEqn GhcRn (LHsType GhcRn)
-> RnM (FamEqn DocNameI (LHsType DocNameI))
rename_ty_fam_eqn (FamEqn { feqn_tycon :: forall pass rhs. FamEqn pass rhs -> Located (IdP pass)
feqn_tycon = Located (IdP GhcRn)
tc, feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> Maybe [LHsTyVarBndr pass]
feqn_bndrs = Maybe [LHsTyVarBndr GhcRn]
bndrs
                              , feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats = HsTyPats GhcRn
pats, feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
                              , feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = LHsType GhcRn
rhs })
      = do { Located DocName
tc' <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
tc
           ; Maybe [LHsTyVarBndr DocNameI]
bndrs' <- ([LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI])
-> Maybe [LHsTyVarBndr GhcRn]
-> RnM (Maybe [LHsTyVarBndr DocNameI])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI))
-> [LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr) Maybe [LHsTyVarBndr GhcRn]
bndrs
           ; [LHsTypeArg DocNameI]
pats' <- (LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI))
-> HsTyPats GhcRn -> RnM [LHsTypeArg DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI)
renameLTypeArg HsTyPats GhcRn
pats
           ; LHsType DocNameI
rhs' <- LHsType GhcRn -> RnM (LHsType DocNameI)
renameLType LHsType GhcRn
rhs
           ; FamEqn DocNameI (LHsType DocNameI)
-> RnM (FamEqn DocNameI (LHsType DocNameI))
forall (m :: * -> *) a. Monad m => a -> m a
return (FamEqn :: forall pass rhs.
XCFamEqn pass rhs
-> Located (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> HsTyPats pass
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
FamEqn { feqn_ext :: XCFamEqn DocNameI (LHsType DocNameI)
feqn_ext    = NoExtField
XCFamEqn DocNameI (LHsType DocNameI)
noExtField
                            , feqn_tycon :: Located (IdP DocNameI)
feqn_tycon  = Located (IdP DocNameI)
Located DocName
tc'
                            , feqn_bndrs :: Maybe [LHsTyVarBndr DocNameI]
feqn_bndrs  = Maybe [LHsTyVarBndr DocNameI]
bndrs'
                            , feqn_pats :: [LHsTypeArg DocNameI]
feqn_pats   = [LHsTypeArg DocNameI]
pats'
                            , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
fixity
                            , feqn_rhs :: LHsType DocNameI
feqn_rhs    = LHsType DocNameI
rhs' }) }
    rename_ty_fam_eqn (XFamEqn XXFamEqn GhcRn (LHsType GhcRn)
nec) = NoExtCon -> RnM (FamEqn DocNameI (LHsType DocNameI))
forall a. NoExtCon -> a
noExtCon NoExtCon
XXFamEqn GhcRn (LHsType GhcRn)
nec

renameTyFamDefltD :: TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamDefltD :: TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamDefltD = TyFamDefltDecl GhcRn -> RnM (TyFamDefltDecl DocNameI)
renameTyFamInstD

renameDataFamInstD :: DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI)
renameDataFamInstD :: DataFamInstDecl GhcRn -> RnM (DataFamInstDecl DocNameI)
renameDataFamInstD (DataFamInstDecl { dfid_eqn :: forall pass.
DataFamInstDecl pass -> FamInstEqn pass (HsDataDefn pass)
dfid_eqn = FamInstEqn GhcRn (HsDataDefn GhcRn)
eqn })
  = do { HsImplicitBndrs DocNameI (FamEqn DocNameI (HsDataDefn DocNameI))
eqn' <- (FamEqn GhcRn (HsDataDefn GhcRn)
 -> RnM (FamEqn DocNameI (HsDataDefn DocNameI)))
-> FamInstEqn GhcRn (HsDataDefn GhcRn)
-> RnM
     (HsImplicitBndrs DocNameI (FamEqn DocNameI (HsDataDefn DocNameI)))
forall in_thing out_thing.
(in_thing -> RnM out_thing)
-> HsImplicitBndrs GhcRn in_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit FamEqn GhcRn (HsDataDefn GhcRn)
-> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
rename_data_fam_eqn FamInstEqn GhcRn (HsDataDefn GhcRn)
eqn
       ; DataFamInstDecl DocNameI -> RnM (DataFamInstDecl DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (DataFamInstDecl :: forall pass.
FamInstEqn pass (HsDataDefn pass) -> DataFamInstDecl pass
DataFamInstDecl { dfid_eqn :: HsImplicitBndrs DocNameI (FamEqn DocNameI (HsDataDefn DocNameI))
dfid_eqn = HsImplicitBndrs DocNameI (FamEqn DocNameI (HsDataDefn DocNameI))
eqn' }) }
  where
    rename_data_fam_eqn
      :: FamEqn GhcRn (HsDataDefn GhcRn)
      -> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
    rename_data_fam_eqn :: FamEqn GhcRn (HsDataDefn GhcRn)
-> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
rename_data_fam_eqn (FamEqn { feqn_tycon :: forall pass rhs. FamEqn pass rhs -> Located (IdP pass)
feqn_tycon = Located (IdP GhcRn)
tc, feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> Maybe [LHsTyVarBndr pass]
feqn_bndrs = Maybe [LHsTyVarBndr GhcRn]
bndrs
                                , feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_pats = HsTyPats GhcRn
pats, feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_fixity = LexicalFixity
fixity
                                , feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_rhs = HsDataDefn GhcRn
defn })
      = do { Located DocName
tc' <- Located Name -> RnM (Located DocName)
renameL Located (IdP GhcRn)
Located Name
tc
           ; Maybe [LHsTyVarBndr DocNameI]
bndrs' <- ([LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI])
-> Maybe [LHsTyVarBndr GhcRn]
-> RnM (Maybe [LHsTyVarBndr DocNameI])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI))
-> [LHsTyVarBndr GhcRn] -> RnM [LHsTyVarBndr DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTyVarBndr GhcRn -> RnM (LHsTyVarBndr DocNameI)
renameLTyVarBndr) Maybe [LHsTyVarBndr GhcRn]
bndrs
           ; [LHsTypeArg DocNameI]
pats' <- (LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI))
-> HsTyPats GhcRn -> RnM [LHsTypeArg DocNameI]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM LHsTypeArg GhcRn -> RnM (LHsTypeArg DocNameI)
renameLTypeArg HsTyPats GhcRn
pats
           ; HsDataDefn DocNameI
defn' <- HsDataDefn GhcRn -> RnM (HsDataDefn DocNameI)
renameDataDefn HsDataDefn GhcRn
defn
           ; FamEqn DocNameI (HsDataDefn DocNameI)
-> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
forall (m :: * -> *) a. Monad m => a -> m a
return (FamEqn :: forall pass rhs.
XCFamEqn pass rhs
-> Located (IdP pass)
-> Maybe [LHsTyVarBndr pass]
-> HsTyPats pass
-> LexicalFixity
-> rhs
-> FamEqn pass rhs
FamEqn { feqn_ext :: XCFamEqn DocNameI (HsDataDefn DocNameI)
feqn_ext    = NoExtField
XCFamEqn DocNameI (HsDataDefn DocNameI)
noExtField
                            , feqn_tycon :: Located (IdP DocNameI)
feqn_tycon  = Located (IdP DocNameI)
Located DocName
tc'
                            , feqn_bndrs :: Maybe [LHsTyVarBndr DocNameI]
feqn_bndrs  = Maybe [LHsTyVarBndr DocNameI]
bndrs'
                            , feqn_pats :: [LHsTypeArg DocNameI]
feqn_pats   = [LHsTypeArg DocNameI]
pats'
                            , feqn_fixity :: LexicalFixity
feqn_fixity = LexicalFixity
fixity
                            , feqn_rhs :: HsDataDefn DocNameI
feqn_rhs    = HsDataDefn DocNameI
defn' }) }
    rename_data_fam_eqn (XFamEqn XXFamEqn GhcRn (HsDataDefn GhcRn)
nec) = NoExtCon -> RnM (FamEqn DocNameI (HsDataDefn DocNameI))
forall a. NoExtCon -> a
noExtCon NoExtCon
XXFamEqn GhcRn (HsDataDefn GhcRn)
nec

renameImplicit :: (in_thing -> RnM out_thing)
               -> HsImplicitBndrs GhcRn in_thing
               -> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit :: (in_thing -> RnM out_thing)
-> HsImplicitBndrs GhcRn in_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
renameImplicit in_thing -> RnM out_thing
rn_thing (HsIB { hsib_body :: forall pass thing. HsImplicitBndrs pass thing -> thing
hsib_body = in_thing
thing })
  = do { out_thing
thing' <- in_thing -> RnM out_thing
rn_thing in_thing
thing
       ; HsImplicitBndrs DocNameI out_thing
-> RnM (HsImplicitBndrs DocNameI out_thing)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsIB :: forall pass thing.
XHsIB pass thing -> thing -> HsImplicitBndrs pass thing
HsIB { hsib_body :: out_thing
hsib_body = out_thing
thing'
                      , hsib_ext :: XHsIB DocNameI out_thing
hsib_ext = NoExtField
XHsIB DocNameI out_thing
noExtField }) }
renameImplicit in_thing -> RnM out_thing
_ (XHsImplicitBndrs XXHsImplicitBndrs GhcRn in_thing
nec) = NoExtCon -> RnM (HsImplicitBndrs DocNameI out_thing)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXHsImplicitBndrs GhcRn in_thing
nec

renameWc :: (in_thing -> RnM out_thing)
         -> HsWildCardBndrs GhcRn in_thing
         -> RnM (HsWildCardBndrs DocNameI out_thing)
renameWc :: (in_thing -> RnM out_thing)
-> HsWildCardBndrs GhcRn in_thing
-> RnM (HsWildCardBndrs DocNameI out_thing)
renameWc in_thing -> RnM out_thing
rn_thing (HsWC { hswc_body :: forall pass thing. HsWildCardBndrs pass thing -> thing
hswc_body = in_thing
thing })
  = do { out_thing
thing' <- in_thing -> RnM out_thing
rn_thing in_thing
thing
       ; HsWildCardBndrs DocNameI out_thing
-> RnM (HsWildCardBndrs DocNameI out_thing)
forall (m :: * -> *) a. Monad m => a -> m a
return (HsWC :: forall pass thing.
XHsWC pass thing -> thing -> HsWildCardBndrs pass thing
HsWC { hswc_body :: out_thing
hswc_body = out_thing
thing'
                      , hswc_ext :: XHsWC DocNameI out_thing
hswc_ext = NoExtField
XHsWC DocNameI out_thing
noExtField }) }
renameWc in_thing -> RnM out_thing
_ (XHsWildCardBndrs XXHsWildCardBndrs GhcRn in_thing
nec) = NoExtCon -> RnM (HsWildCardBndrs DocNameI out_thing)
forall a. NoExtCon -> a
noExtCon NoExtCon
XXHsWildCardBndrs GhcRn in_thing
nec

renameDocInstance :: DocInstance GhcRn -> RnM (DocInstance DocNameI)
renameDocInstance :: DocInstance GhcRn -> RnM (DocInstance DocNameI)
renameDocInstance (InstHead GhcRn
inst, Maybe (MDoc (IdP GhcRn))
idoc, L SrcSpan
l IdP GhcRn
n, Maybe Module
m) = do
  InstHead DocNameI
inst' <- InstHead GhcRn -> RnM (InstHead DocNameI)
renameInstHead InstHead GhcRn
inst
  DocName
n' <- Name -> RnM DocName
rename IdP GhcRn
Name
n
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
idoc' <- (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
 -> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
-> Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
-> RnM
     (Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc Maybe (MDoc (IdP GhcRn))
Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name))
idoc
  (InstHead DocNameI,
 Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
 Located DocName, Maybe Module)
-> RnM
     (InstHead DocNameI,
      Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
      Located DocName, Maybe Module)
forall (m :: * -> *) a. Monad m => a -> m a
return (InstHead DocNameI
inst', Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
idoc', SrcSpan -> DocName -> Located DocName
forall l e. l -> e -> GenLocated l e
L SrcSpan
l DocName
n', Maybe Module
m)

renameExportItem :: ExportItem GhcRn -> RnM (ExportItem DocNameI)
renameExportItem :: ExportItem GhcRn -> RnM (ExportItem DocNameI)
renameExportItem ExportItem GhcRn
item = case ExportItem GhcRn
item of
  ExportModule Module
mdl -> ExportItem DocNameI -> RnM (ExportItem DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Module -> ExportItem DocNameI
forall name. Module -> ExportItem name
ExportModule Module
mdl)
  ExportGroup Int
lev String
id_ Doc (IdP GhcRn)
doc -> do
    Doc DocName
doc' <- Doc Name -> RnM (Doc DocName)
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc Doc (IdP GhcRn)
Doc Name
doc
    ExportItem DocNameI -> RnM (ExportItem DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> String -> Doc (IdP DocNameI) -> ExportItem DocNameI
forall name. Int -> String -> Doc (IdP name) -> ExportItem name
ExportGroup Int
lev String
id_ Doc (IdP DocNameI)
Doc DocName
doc')
  ExportDecl LHsDecl GhcRn
decl [(HsDecl GhcRn, DocForDecl (IdP GhcRn))]
pats DocForDecl (IdP GhcRn)
doc [(IdP GhcRn, DocForDecl (IdP GhcRn))]
subs [DocInstance GhcRn]
instances [(IdP GhcRn, Fixity)]
fixities Bool
splice -> do
    LHsDecl DocNameI
decl' <- LHsDecl GhcRn -> RnM (LHsDecl DocNameI)
renameLDecl LHsDecl GhcRn
decl
    [(HsDecl DocNameI, DocForDecl DocName)]
pats' <- [(HsDecl GhcRn, DocForDecl Name)]
-> RnM [(HsDecl DocNameI, DocForDecl DocName)]
renamePats [(HsDecl GhcRn, DocForDecl (IdP GhcRn))]
[(HsDecl GhcRn, DocForDecl Name)]
pats
    DocForDecl DocName
doc'  <- DocForDecl Name -> RnM (DocForDecl DocName)
renameDocForDecl DocForDecl (IdP GhcRn)
DocForDecl Name
doc
    [(DocName, DocForDecl DocName)]
subs' <- ((Name, DocForDecl Name) -> RnM (DocName, DocForDecl DocName))
-> [(Name, DocForDecl Name)] -> RnM [(DocName, DocForDecl DocName)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Name, DocForDecl Name) -> RnM (DocName, DocForDecl DocName)
renameSub [(IdP GhcRn, DocForDecl (IdP GhcRn))]
[(Name, DocForDecl Name)]
subs
    [(InstHead DocNameI,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
  Located DocName, Maybe Module)]
instances' <- [(InstHead GhcRn,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
  Located Name, Maybe Module)]
-> ((InstHead GhcRn,
     Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
     Located Name, Maybe Module)
    -> RnM
         (InstHead DocNameI,
          Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
          Located DocName, Maybe Module))
-> RnM
     [(InstHead DocNameI,
       Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
       Located DocName, Maybe Module)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [DocInstance GhcRn]
[(InstHead GhcRn,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
  Located Name, Maybe Module)]
instances DocInstance GhcRn -> RnM (DocInstance DocNameI)
(InstHead GhcRn,
 Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)),
 Located Name, Maybe Module)
-> RnM
     (InstHead DocNameI,
      Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
      Located DocName, Maybe Module)
renameDocInstance
    [(DocName, Fixity)]
fixities' <- [(Name, Fixity)]
-> ((Name, Fixity) -> RnM (DocName, Fixity))
-> RnM [(DocName, Fixity)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [(IdP GhcRn, Fixity)]
[(Name, Fixity)]
fixities (((Name, Fixity) -> RnM (DocName, Fixity))
 -> RnM [(DocName, Fixity)])
-> ((Name, Fixity) -> RnM (DocName, Fixity))
-> RnM [(DocName, Fixity)]
forall a b. (a -> b) -> a -> b
$ \(Name
name, Fixity
fixity) -> do
      DocName
name' <- Name -> RnM DocName
lookupRn Name
name
      (DocName, Fixity) -> RnM (DocName, Fixity)
forall (m :: * -> *) a. Monad m => a -> m a
return (DocName
name', Fixity
fixity)
    ExportItem DocNameI -> RnM (ExportItem DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (LHsDecl DocNameI
-> [(HsDecl DocNameI, DocForDecl (IdP DocNameI))]
-> DocForDecl (IdP DocNameI)
-> [(IdP DocNameI, DocForDecl (IdP DocNameI))]
-> [DocInstance DocNameI]
-> [(IdP DocNameI, Fixity)]
-> Bool
-> ExportItem DocNameI
forall name.
LHsDecl name
-> [(HsDecl name, DocForDecl (IdP name))]
-> DocForDecl (IdP name)
-> [(IdP name, DocForDecl (IdP name))]
-> [DocInstance name]
-> [(IdP name, Fixity)]
-> Bool
-> ExportItem name
ExportDecl LHsDecl DocNameI
decl' [(HsDecl DocNameI, DocForDecl (IdP DocNameI))]
[(HsDecl DocNameI, DocForDecl DocName)]
pats' DocForDecl (IdP DocNameI)
DocForDecl DocName
doc' [(IdP DocNameI, DocForDecl (IdP DocNameI))]
[(DocName, DocForDecl DocName)]
subs' [DocInstance DocNameI]
[(InstHead DocNameI,
  Maybe (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)),
  Located DocName, Maybe Module)]
instances' [(IdP DocNameI, Fixity)]
[(DocName, Fixity)]
fixities' Bool
splice)
  ExportNoDecl IdP GhcRn
x [IdP GhcRn]
subs -> do
    DocName
x'    <- Name -> RnM DocName
lookupRn IdP GhcRn
Name
x
    [DocName]
subs' <- (Name -> RnM DocName) -> [Name] -> RnM [DocName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Name -> RnM DocName
lookupRn [IdP GhcRn]
[Name]
subs
    ExportItem DocNameI -> RnM (ExportItem DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (IdP DocNameI -> [IdP DocNameI] -> ExportItem DocNameI
forall name. IdP name -> [IdP name] -> ExportItem name
ExportNoDecl IdP DocNameI
DocName
x' [IdP DocNameI]
[DocName]
subs')
  ExportDoc MDoc (IdP GhcRn)
doc -> do
    MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)
doc' <- MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
-> RnM (MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName))
forall (t :: * -> *).
Traversable t =>
t (Wrap Name) -> RnM (t (Wrap DocName))
renameDoc MDoc (IdP GhcRn)
MetaDoc (Wrap (ModuleName, OccName)) (Wrap Name)
doc
    ExportItem DocNameI -> RnM (ExportItem DocNameI)
forall (m :: * -> *) a. Monad m => a -> m a
return (MDoc (IdP DocNameI) -> ExportItem DocNameI
forall name. MDoc (IdP name) -> ExportItem name
ExportDoc MDoc (IdP DocNameI)
MetaDoc (Wrap (ModuleName, OccName)) (Wrap DocName)
doc')


renameSub :: (Name, DocForDecl Name) -> RnM (DocName, DocForDecl DocName)
renameSub :: (Name, DocForDecl Name) -> RnM (DocName, DocForDecl DocName)
renameSub (Name
n,DocForDecl Name
doc) = do
  DocName
n' <- Name -> RnM DocName
rename Name
n
  DocForDecl DocName
doc' <- DocForDecl Name -> RnM (DocForDecl DocName)
renameDocForDecl DocForDecl Name
doc
  (DocName, DocForDecl DocName) -> RnM (DocName, DocForDecl DocName)
forall (m :: * -> *) a. Monad m => a -> m a
return (DocName
n', DocForDecl DocName
doc')