@@ -109,13 +109,14 @@ moduleHeader = try (do noDocCommentHere "Modules cannot have documentation c
109109 Import ::= 'import' Identifier_t ';'?;
110110@
111111 -}
112−import_ :: IdrisParser (String, Maybe String, FC)
112+import_ :: IdrisParser (Bool, String, Maybe String, FC)
113113import_ = do fc <- getFC
114114 reserved "import"
115+ reexport <- option False (do reserved "public"; return True)
115116 id <- identifier
116117 newName <- optional (reserved "as" *> identifier)
117118 option ';' (lchar ';')
118− return (toPath id, toPath <$> newName, fc)
119+ return (reexport, toPath id, toPath <$> newName, fc)
119120 <?> "import statement"
120121 where toPath = foldl1' (</>) . Spl.splitOn "."
121122
@@ -1132,14 +1133,14 @@ parseTactic :: IState -> String -> Result PTactic
11321133parseTactic st = runparser (fullTactic defaultSyntax) st "(input)"
11331134
11341135-- | Parse module header and imports
1135−parseImports :: FilePath -> String -> Idris ([String], [(String, Maybe String, FC)], Maybe Delta)
1136+parseImports :: FilePath -> String -> Idris ([String], [(Bool, String, Maybe String, FC)], Maybe Delta)
11361137parseImports fname input
11371138 = do i <- getIState
11381139 case parseString (runInnerParser (evalStateT imports i)) (Directed (UTF8.fromString fname) 0 0 0 0) input of
11391140 Failure err -> fail (show err)
11401141 Success (x, i) -> do putIState i
11411142 return x
1142− where imports :: IdrisParser (([String], [(String, Maybe String, FC)], Maybe Delta), IState)
1143+ where imports :: IdrisParser (([String], [(Bool, String, Maybe String, FC)], Maybe Delta), IState)
11431144 imports = do whiteSpace
11441145 mname <- moduleHeader
11451146 ps <- many import_
@@ -1219,7 +1220,7 @@ loadModule' f
12191220 IDR fn -> loadSource False fn Nothing
12201221 LIDR fn -> loadSource True fn Nothing
12211222 IBC fn src ->
1222− idrisCatch (loadIBC fn)
1223+ idrisCatch (loadIBC True fn)
12231224 (\c -> do iLOG $ fn ++ " failed " ++ pshow i c
12241225 case src of
12251226 IDR sfn -> loadSource False sfn Nothing
@@ -1229,18 +1230,18 @@ loadModule' f
12291230
12301231
12311232{- | Load idris code from file -}
1232−loadFromIFile :: IFileType -> Maybe Int -> Idris ()
1233−loadFromIFile i@(IBC fn src) maxline
1233+loadFromIFile :: Bool -> IFileType -> Maybe Int -> Idris ()
1234+loadFromIFile reexp i@(IBC fn src) maxline
12341235 = do iLOG $ "Skipping " ++ getSrcFile i
1235− idrisCatch (loadIBC fn)
1236+ idrisCatch (loadIBC reexp fn)
12361237 (\err -> ierror $ LoadingFailed fn err)
12371238 where
12381239 getSrcFile (IDR fn) = fn
12391240 getSrcFile (LIDR fn) = fn
12401241 getSrcFile (IBC f src) = getSrcFile src
12411242
1242−loadFromIFile (IDR fn) maxline = loadSource' False fn maxline
1243−loadFromIFile (LIDR fn) maxline = loadSource' True fn maxline
1243+loadFromIFile _ (IDR fn) maxline = loadSource' False fn maxline
1244+loadFromIFile _ (LIDR fn) maxline = loadSource' True fn maxline
12441245
12451246{-| Load idris source code and show error if something wrong happens -}
12461247loadSource' :: Bool -> FilePath -> Maybe Int -> Idris ()
@@ -1262,22 +1263,23 @@ loadSource lidr f toline
12621263 file <- if lidr then tclift $ unlit f file_in else return file_in
12631264 (mname, imports_in, pos) <- parseImports f file
12641265 ai <- getAutoImports
1265− let imports = map (\n -> (n, Just n, emptyFC)) ai ++ imports_in
1266+ let imports = map (\n -> (True, n, Just n, emptyFC)) ai ++ imports_in
12661267 ids <- allImportDirs
12671268 ibcsd <- valIBCSubDir i
1268− mapM_ (\f -> do fp <- findImport ids ibcsd f
1269+ mapM_ (\(re, f) ->
1270+ do fp <- findImport ids ibcsd f
12691271 case fp of
12701272 LIDR fn -> ifail $ "No ibc for " ++ f
12711273 IDR fn -> ifail $ "No ibc for " ++ f
1272− IBC fn src -> loadIBC fn)
1273− [fn | (fn, _, _) <- imports]
1274+ IBC fn src -> loadIBC True fn)
1275+ [(re, fn) | (re, fn, _, _) <- imports]
12741276 reportParserWarnings
12751277
12761278 -- process and check module aliases
12771279 let modAliases = M.fromList
1278− [(prep alias, prep realName) | (realName, Just alias, fc) <- imports]
1280+ [(prep alias, prep realName) | (reexport, realName, Just alias, fc) <- imports]
12791281 prep = map T.pack . reverse . Spl.splitOn "/"
1280− aliasNames = [(alias, fc) | (_, Just alias, fc) <- imports]
1282+ aliasNames = [(alias, fc) | (_, _, Just alias, fc) <- imports]
12811283 histogram = groupBy ((==) `on` fst) . sortBy (comparing fst) $ aliasNames
12821284 case map head . filter ((/= 1) . length) $ histogram of
12831285 [] -> logLvl 3 $ "Module aliases: " ++ show (M.toList modAliases)
@@ -1289,7 +1291,7 @@ loadSource lidr f toline
12891291 -- record package info in .ibc
12901292 imps <- allImportDirs
12911293 mapM_ addIBC (map IBCImportDir imps)
1292− mapM_ (addIBC . IBCImport) [realName | (realName, alias, fc) <- imports]
1294+ mapM_ (addIBC . IBCImport) [(reexport, realName) | (reexport, realName, alias, fc) <- imports]
12931295 let syntax = defaultSyntax{ syn_namespace = reverse mname,
12941296 maxline = toline }
12951297 ds' <- parseProg syntax f file pos