git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix for modules with dotted names in psci
89970f7Gary Burgess
psci/Main.hs+6−6
@@ -48,7 +48,7 @@ import qualified Text.Parsec as Parsec (Parsec, eof, try)
48-- The let bindings are partial,
48-- The let bindings are partial,
49-- because it makes more sense to apply the binding to the final evaluated expression.
49-- because it makes more sense to apply the binding to the final evaluated expression.
50--
50--
51−data PSCI = PSCI [P.ProperName] [P.Module] [P.Value -> P.Value]
51+data PSCI = PSCI [P.ModuleName] [P.Module] [P.Value -> P.Value]
52
52
53-- State helpers
53-- State helpers
54
54
@@ -70,7 +70,7 @@ ioToState = lift . lift
70-- Updates the state to have more imported modules.
70-- Updates the state to have more imported modules.
71--
71--
72updateImports :: String -> PSCI -> PSCI
72updateImports :: String -> PSCI -> PSCI
73−updateImports name (PSCI i m b) = PSCI (i ++ [P.ProperName name]) m b
73+updateImports name (PSCI i m b) = PSCI (P.moduleNameFromString name : i) m b
74
74
75-- |
75-- |
76-- Updates the state to have more loaded files.
76-- Updates the state to have more loaded files.
@@ -88,8 +88,8 @@ updateLets name (PSCI i m b) = PSCI i m (b ++ [name])
88-- |
88-- |
89-- Load the necessary modules.
89-- Load the necessary modules.
90--
90--
91−defaultImports :: [P.ProperName]
91+defaultImports :: [P.ModuleName]
92−defaultImports = [P.ProperName "Prelude"]
92+defaultImports = [P.ModuleName [P.ProperName "Prelude"]]
93
93
94-- |
94-- |
95-- Locates the node executable.
95-- Locates the node executable.
@@ -191,7 +191,7 @@ options = P.Options True False True (Just "Main") True "PS" []
191-- |
191-- |
192-- Makes a volatile module to execute the current expression.
192-- Makes a volatile module to execute the current expression.
193--
193--
194−createTemporaryModule :: Bool -> [P.ProperName] -> [P.Value -> P.Value] -> P.Value -> P.Module
194+createTemporaryModule :: Bool -> [P.ModuleName] -> [P.Value -> P.Value] -> P.Value -> P.Module
195createTemporaryModule exec imports lets value =
195createTemporaryModule exec imports lets value =
196 let
196 let
197 moduleName = P.ModuleName [P.ProperName "Main"]
197 moduleName = P.ModuleName [P.ProperName "Main"]
@@ -202,7 +202,7 @@ createTemporaryModule exec imports lets value =
202 itDecl = P.ValueDeclaration (P.Ident "it") [] Nothing value'
202 itDecl = P.ValueDeclaration (P.Ident "it") [] Nothing value'
203 mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing (P.App trace (P.Var (P.Qualified Nothing (P.Ident "it"))))
203 mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing (P.App trace (P.Var (P.Qualified Nothing (P.Ident "it"))))
204 in
204 in
205− P.Module moduleName $ map (importDecl . P.ModuleName . return) imports ++ if exec then [itDecl, mainDecl] else [itDecl]
205+ P.Module moduleName $ map importDecl imports ++ if exec then [itDecl, mainDecl] else [itDecl]
206
206
207-- |
207-- |
208-- Takes a value declaration and evaluates it with the current state.
208-- Takes a value declaration and evaluates it with the current state.