git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
validate imports correctly
commit206bb51e4ec2499715cdbd7aa0aada77366f4fbb authorBogdan Popa <popa.bogdanp@gmail.com> dateWed 15 Oct 2014, 12:00 (12 years ago) parent61392d9
1 file changed+13−9
psci/Main.hs+13−9
psci/Main.hs+13−9
@@ -233,14 +233,6 @@ instance P.MonadMake Make where
233233mkdirp :: FilePath -> IO ()
234234mkdirp = createDirectoryIfMissing True . takeDirectory
235235
236−-- |
237−-- Just an empty module.
238−--
239−emptyModule :: P.Module
240−emptyModule =
241− let moduleName = P.ModuleName [P.ProperName "$PSCI"]
242− in P.Module moduleName [] Nothing
243−
244236-- |
245237-- Makes a volatile module to execute the current expression.
246238--
@@ -271,6 +263,17 @@ createTemporaryModuleForKind PSCiState{psciImportedModuleNames = imports} typ =
271263 in
272264 P.Module moduleName ((importDecl `map` imports) ++ [itDecl]) Nothing
273265
266+-- |
267+-- Makes a volatile module to execute the current imports.
268+--
269+createTemporaryModuleForImports :: PSCiState -> P.Module
270+createTemporaryModuleForImports PSCiState{psciImportedModuleNames = imports} =
271+ let
272+ moduleName = P.ModuleName [P.ProperName "$PSCI"]
273+ importDecl m = P.ImportDeclaration m P.Unqualified Nothing
274+ in
275+ P.Module moduleName (importDecl `map` imports) Nothing
276+
274277modulesDir :: FilePath
275278modulesDir = ".psci_modules" ++ pathSeparator : "node_modules"
276279
@@ -302,7 +305,8 @@ handleDeclaration value = do
302305handleImport :: P.ModuleName -> PSCI ()
303306handleImport moduleName = do
304307 s <- liftM (updateImports moduleName) $ PSCI $ lift get
305− e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules s ++ [("$PSCI.purs", emptyModule)]) []
308+ let m = createTemporaryModuleForImports s
309+ e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules s ++ [("$PSCI.purs", m)]) []
306310 case e of
307311 Left err -> PSCI $ outputStrLn err
308312 Right _ -> do