@@ -16,7 +16,6 @@ import Control.Concurrent.Strict (modifyVar, newVar)
16
16
import Control.DeepSeq (force )
17
17
import Control.Exception (evaluate , mask , throwIO )
18
18
import Control.Monad.Extra (eitherM , join , mapMaybeM )
19
- import Control.Monad.IO.Class
20
19
import Data.Either (fromRight )
21
20
import Data.Set (Set )
22
21
import qualified Data.Set as Set
@@ -76,22 +75,25 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do
76
75
-- compute the package imports
77
76
let pkgst = unitState hscEnv
78
77
depends = explicitUnits pkgst
79
- targets =
80
- [ (pkg, mn)
78
+ modules =
79
+ [ m
81
80
| d <- depends
82
81
, Just pkg <- [lookupPackageConfig d hscEnv]
83
- , (mn, _) <- unitExposedModules pkg
82
+ , (modName, maybeOtherPkgMod) <- unitExposedModules pkg
83
+ , let m = case maybeOtherPkgMod of
84
+ -- When module is re-exported from another package,
85
+ -- the origin module is represented by value in Just
86
+ Just otherPkgMod -> otherPkgMod
87
+ Nothing -> mkModule (unitInfoId pkg) modName
84
88
]
85
89
86
- doOne (pkg, mn) = do
87
- modIface <- liftIO $ initIfaceLoad hscEnv $ loadInterface
88
- " "
89
- (mkModule (unitInfoId pkg) mn)
90
- (ImportByUser NotBoot )
90
+ doOne m = do
91
+ modIface <- initIfaceLoad hscEnv $
92
+ loadInterface " " m (ImportByUser NotBoot )
91
93
return $ case modIface of
92
94
Maybes. Failed _r -> Nothing
93
95
Maybes. Succeeded mi -> Just mi
94
- modIfaces <- mapMaybeM doOne targets
96
+ modIfaces <- mapMaybeM doOne modules
95
97
return $ createExportsMap modIfaces
96
98
97
99
-- similar to envPackageExports, evaluated lazily
0 commit comments