git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #544 from 5outh/psci-module-change

Move PSCi Temp Module from Main to $PSCI

commit905041cc59cfa975509c28d275e91e5f31e049cf authorPhil Freeman <paf31@cantab.net> dateTue 5 Aug 2014, 11:01 (12 years ago) parent60346a38bd3795
1 file changed+10−9
psci/Main.hs+10−9
psci/Main.hs+10−9
@@ -234,7 +234,7 @@ instance P.MonadMake Make where
234234 mkdirp path
235235 U.writeFile path text
236236 liftError = either throwError return
237− progress s = unless (s == "Compiling Main") $ makeIO . U.putStrLn $ s
237+ progress s = unless (s == "Compiling $PSCI") $ makeIO . U.putStrLn $ s
238238
239239mkdirp :: FilePath -> IO ()
240240mkdirp = createDirectoryIfMissing True . takeDirectory
@@ -245,7 +245,7 @@ mkdirp = createDirectoryIfMissing True . takeDirectory
245245createTemporaryModule :: Bool -> PSCiState -> P.Expr -> P.Module
246246createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetBindings = lets} value =
247247 let
248− moduleName = P.ModuleName [P.ProperName "Main"]
248+ moduleName = P.ModuleName [P.ProperName "$PSCI"]
249249 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
250250 traceModule = P.ModuleName [P.ProperName "Debug", P.ProperName "Trace"]
251251 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
@@ -263,7 +263,7 @@ createTemporaryModule exec PSCiState{psciImportedModuleNames = imports, psciLetB
263263createTemporaryModuleForKind :: PSCiState -> P.Type -> P.Module
264264createTemporaryModuleForKind PSCiState{psciImportedModuleNames = imports} typ =
265265 let
266− moduleName = P.ModuleName [P.ProperName "Main"]
266+ moduleName = P.ModuleName [P.ProperName "$PSCI"]
267267 importDecl m = P.ImportDeclaration m P.Unqualified Nothing
268268 itDecl = P.TypeSynonymDeclaration (P.ProperName "IT") [] typ
269269 in
@@ -282,11 +282,11 @@ handleDeclaration :: P.Expr -> PSCI ()
282282handleDeclaration value = do
283283 st <- PSCI $ lift get
284284 let m = createTemporaryModule True st value
285− e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("Main.purs", m)])
285+ e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("$PSCI.purs", m)])
286286 case e of
287287 Left err -> PSCI $ outputStrLn err
288288 Right _ -> do
289− psciIO $ writeFile indexFile $ "require('Main').main();"
289+ psciIO $ writeFile indexFile $ "require('$PSCI').main();"
290290 process <- psciIO findNodeProcess
291291 result <- psciIO $ traverse (\node -> readProcessWithExitCode node [indexFile] "") process
292292 case result of
@@ -301,11 +301,11 @@ handleTypeOf :: P.Expr -> PSCI ()
301301handleTypeOf value = do
302302 st <- PSCI $ lift get
303303 let m = createTemporaryModule False st value
304− e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("Main.purs", m)])
304+ e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("$PSCI.purs", m)])
305305 case e of
306306 Left err -> PSCI $ outputStrLn err
307307 Right env' ->
308− case M.lookup (P.ModuleName [P.ProperName "Main"], P.Ident "it") (P.names env') of
308+ case M.lookup (P.ModuleName [P.ProperName "$PSCI"], P.Ident "it") (P.names env') of
309309 Just (ty, _, _) -> PSCI . outputStrLn . P.prettyPrintType $ ty
310310 Nothing -> PSCI $ outputStrLn "Could not find type"
311311
@@ -316,8 +316,8 @@ handleKindOf :: P.Type -> PSCI ()
316316handleKindOf typ = do
317317 st <- PSCI $ lift get
318318 let m = createTemporaryModuleForKind st typ
319− mName = P.ModuleName [P.ProperName "Main"]
320− e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("Main.purs", m)])
319+ mName = P.ModuleName [P.ProperName "$PSCI"]
320+ e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("$PSCI.purs", m)])
321321 case e of
322322 Left err -> PSCI $ outputStrLn err
323323 Right env' ->
@@ -340,6 +340,7 @@ getCommand = do
340340 firstLine <- getInputLine "> "
341341 case firstLine of
342342 Nothing -> return (Right Nothing)
343+ Just "" -> return (Right Nothing)
343344 Just s@ (':' : _) -> return . either Left (Right . Just) $ parseCommand s -- The start of a command
344345 Just s -> either Left (Right . Just) . parseCommand <$> go [s]
345346 where