aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
authoralexbiehl <alex.biehl@gmail.com>2017-10-31 22:28:34 +0100
committeralexbiehl <alex.biehl@gmail.com>2017-10-31 22:28:34 +0100
commit2be7dcf62f945a765ee403f91530e43203efc948 (patch)
tree83b3b1566aca0bf1710807ac197863b6aad6c919 /haddock-api
parent08c9e19236770811caf571321f5ece271d1fccff (diff)
fullModuleContents traverses exports in declaration order
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 9bf21e52..096fdda3 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -38,7 +38,6 @@ import qualified Data.Map as M
import Data.Map (Map)
import Data.List
import Data.Maybe
-import Data.Monoid
import Data.Ord
import Control.Applicative
import Control.Exception (evaluate)
@@ -55,6 +54,7 @@ import GHC
import HscTypes
import Name
import NameSet
+import NameEnv
import Bag
import RdrName
import TcRnTypes
@@ -626,7 +626,7 @@ mkExportItems
case exportList of
Nothing ->
fullModuleContents is_sig modMap thisMod semMod warnings exportedNames
- maps fixMap splices instIfaceMap dflags allExports
+ decls maps fixMap splices instIfaceMap dflags allExports
Just exports -> liftM concat $ mapM lookupExport exports
where
lookupExport (IEGroup lev docStr, _) = liftErrMsg $ do
@@ -955,6 +955,7 @@ fullModuleContents :: Bool -- is it a signature
-> Module -- semantic module
-> WarningMap
-> [Name] -- exported names (orig)
+ -> [LHsDecl GhcRn] -- renamed source declarations
-> Maps
-> FixMap
-> [SrcSpan] -- splice locations
@@ -963,11 +964,15 @@ fullModuleContents :: Bool -- is it a signature
-> Avails
-> ErrMsgGhc [ExportItem GhcRn]
fullModuleContents is_sig modMap thisMod semMod warnings exportedNames
- maps fixMap splices instIfaceMap dflags avails =
-
- concat <$> traverse (availExportItem is_sig modMap thisMod
+ decls maps fixMap splices instIfaceMap dflags avails = do
+ let availEnv = availsToNameEnv avails
+ (concat . concat) `fmap` (for decls $ \decl -> do
+ for (getMainDeclBinder (unLoc decl)) $ \nm -> do
+ case lookupNameEnv availEnv nm of
+ Just avail -> availExportItem is_sig modMap thisMod
semMod warnings exportedNames maps fixMap
- splices instIfaceMap dflags) avails
+ splices instIfaceMap dflags avail
+ Nothing -> pure [])
-- | Sometimes the declaration we want to export is not the "main" declaration:
-- it might be an individual record selector or a class method. In these