git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Rename default 'main' in psci

This allows people to use main inside psci without getting unexplained (from their point of view, at least) errors

commit50b4c6d735ddd56bb9e584b2351b8ac241defb4b authorHarry Garrood <harry@garrood.me> dateSat 19 Dec 2015, 00:04 (11 years ago) parent0c87efe
1 file changed+2−2
psci/PSCi.hs+2−2
psci/PSCi.hs+2−2
@@ -202,7 +202,7 @@ createTemporaryModule exec PSCiState{psciImportedModules = imports, psciLetBindi
202202 trace = P.Var (P.Qualified (Just supportModuleName) (P.Ident "eval"))
203203 mainValue = P.App trace (P.Var (P.Qualified Nothing (P.Ident "it")))
204204 itDecl = P.ValueDeclaration (P.Ident "it") P.Public [] $ Right val
205− mainDecl = P.ValueDeclaration (P.Ident "main") P.Public [] $ Right mainValue
205+ mainDecl = P.ValueDeclaration (P.Ident "$main") P.Public [] $ Right mainValue
206206 decls = if exec then [itDecl, mainDecl] else [itDecl]
207207 in
208208 P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName ((importDecl `map` imports) ++ lets ++ decls) Nothing
@@ -267,7 +267,7 @@ handleDeclaration val = do
267267 case e of
268268 Left errs -> printErrors errs
269269 Right _ -> do
270− psciIO $ writeFile indexFile "require('$PSCI').main();"
270+ psciIO $ writeFile indexFile "require('$PSCI')['$main']();"
271271 process <- psciIO findNodeProcess
272272 result <- psciIO $ traverse (\node -> readProcessWithExitCode node nodeArgs "") process
273273 case result of