on master help sign in
Don't read so much when just changing the reexport status of a module
commitc4f3c1e27afbdd02604768d399fc8c7d95b407bc authorNiklas Larsson <niklas@mm.st> dateSat 26 Mar 2016, 02:07 (11 years ago) parent3303747
1 file changed+28−14
src/Idris/IBC.hs+28−14
src/Idris/IBC.hs+28−14
@@ -113,23 +113,32 @@ hasValidIBCVersion fp = do
113113 Right archive -> do ver <- getEntry 0 "ver" archive
114114 return (ver == ibcVersion)
115115
116+data ImpAction = FullLoad | Unhide | NoAction deriving (Eq, Show)
117+
116118loadIBC :: Bool -- ^ True = reexport, False = make everything private
117119 -> IBCPhase
118120 -> FilePath -> Idris ()
119121loadIBC reexport phase fp
120122 = do imps <- getImported
121− let redo = case lookup fp imps of
122− Nothing -> True
123− Just p -> not p && reexport
124− when redo $
125− do logIBC 1 $ "Loading ibc " ++ fp ++ " " ++ show reexport
126− archiveFile <- runIO $ B.readFile fp
127− case toArchiveOrFail archiveFile of
128− Left _ -> ifail $ fp ++ " isn't loadable, it may have an old ibc format.\n"
129− ++ "Please clean and rebuild it."
130− Right archive -> do process reexport phase archive fp
131− addImported reexport fp
132−-- dumpTT
123+ let action = case lookup fp imps of
124+ Nothing -> FullLoad
125+ Just p -> if (not p && reexport) then Unhide else NoAction
126+ when (action /= NoAction) $ do
127+ logIBC 1 $ "Loading ibc " ++ fp ++ " " ++ show reexport
128+ archiveFile <- runIO $ B.readFile fp
129+ case toArchiveOrFail archiveFile of
130+ Left _ -> do
131+ ifail $ fp ++ " isn't loadable, it may have an old ibc format.\n"
132+ ++ "Please clean and rebuild it."
133+ Right archive -> do
134+ case action of
135+ FullLoad -> do
136+ process reexport phase archive fp
137+ addImported reexport fp
138+ Unhide -> do
139+ unhide phase archive
140+ addImported reexport fp
141+ _ -> return ()
133142
134143-- | Load an entire package from its index file
135144loadPkgIndex :: String -> Idris ()
@@ -324,8 +333,13 @@ getEntry alt f a = case findEntryByPath f a of
324333 Nothing -> return alt
325334 Just e -> return $! (force . decode . fromEntry) e
326335
336+unhide :: IBCPhase -> Archive -> Idris ()
337+unhide phase ar = do
338+ pImports True phase =<< getEntry [] "ibc_imports" ar
339+ pAccess True phase =<< getEntry [] "ibc_access" ar
340+
327341process :: Bool -- ^ Reexporting
328− -> IBCPhase
342+ -> IBCPhase
329343 -> Archive -> FilePath -> Idris ()
330344process reexp phase i fn = do
331345 ver <- getEntry 0 "ver" i
@@ -616,7 +630,7 @@ pAccess reexp phase ds
616630 else logIBC 1 $ "Exporting " ++ show n
617631 -- Everything should be available at the REPL from
618632 -- things imported publicly
619− when (phase == IBC_REPL True) $
633+ when (phase == IBC_REPL True) $
620634 setAccessibility n Public
621635 ) ds
622636