diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Haddock/GHC/Utils.hs | 31 | ||||
-rw-r--r-- | src/Haddock/Interface/Rename.hs | 8 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/Haddock/GHC/Utils.hs b/src/Haddock/GHC/Utils.hs index c0e73425..7cbcf07f 100644 --- a/src/Haddock/GHC/Utils.hs +++ b/src/Haddock/GHC/Utils.hs @@ -17,6 +17,8 @@ import Data.Char import Data.Version import qualified Data.Map as Map import Control.Arrow +import Data.Foldable hiding (concatMap) +import Data.Traversable import HsSyn import SrcLoc @@ -26,14 +28,6 @@ import Packages import Module -unL :: Located a -> a -unL (L _ x) = x - - -reL :: a -> Located a -reL = L undefined - - moduleString :: Module -> String moduleString = moduleNameString . moduleName @@ -118,6 +112,27 @@ trace_ppr x y = trace (pretty x) y ------------------------------------------------------------------------------- +-- Located +------------------------------------------------------------------------------- + + +unL :: Located a -> a +unL (L _ x) = x + + +reL :: a -> Located a +reL = L undefined + + +instance Foldable Located where + foldMap f (L _ x) = f x + + +instance Traversable Located where + mapM f (L l x) = (return . L l) =<< f x + + +------------------------------------------------------------------------------- -- NamedThing instances ------------------------------------------------------------------------------- diff --git a/src/Haddock/Interface/Rename.hs b/src/Haddock/Interface/Rename.hs index 6d806806..17fe1223 100644 --- a/src/Haddock/Interface/Rename.hs +++ b/src/Haddock/Interface/Rename.hs @@ -129,8 +129,12 @@ runRnFM env rn = unRn rn lkp -------------------------------------------------------------------------------- -rename = lookupRn id -renameL (L loc name) = return . L loc =<< rename name +rename :: Name -> RnM DocName +rename = lookupRn id + + +renameL :: Located Name -> RnM (Located DocName) +renameL = mapM rename renameExportItems :: [ExportItem Name] -> RnM [ExportItem DocName] |