git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
A few comments.
8559375joneshf
psci/Main.hs+14−10
@@ -58,18 +58,18 @@ updateBinders :: P.DoNotationElement -> PSCI -> PSCI
58updateBinders name (PSCI i m b) = PSCI i m (b ++ [name])
58updateBinders name (PSCI i m b) = PSCI i m (b ++ [name])
59
59
60-- File helpers
60-- File helpers
61−getHistoryFilename :: IO FilePath
61+defaultImports :: [P.ProperName]
62−getHistoryFilename = getUserConfigFile "purescript" "psci_history"
62+defaultImports = [P.ProperName "Prelude", P.ProperName "Eff"]
63−
64−getPreludeFilename :: IO FilePath
65−getPreludeFilename = Paths.getDataFileName "prelude/prelude.purs"
66
63
67findNodeProcess :: IO (Maybe String)
64findNodeProcess :: IO (Maybe String)
68findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
65findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
69 where names = ["nodejs", "node"]
66 where names = ["nodejs", "node"]
70
67
71−defaultImports :: [P.ProperName]
68+getHistoryFilename :: IO FilePath
72−defaultImports = [P.ProperName "Prelude", P.ProperName "Eff"]
69+getHistoryFilename = getUserConfigFile "purescript" "psci_history"
70+
71+getPreludeFilename :: IO FilePath
72+getPreludeFilename = Paths.getDataFileName "prelude/prelude.purs"
73
73
74loadModule :: FilePath -> IO (Either String [P.Module])
74loadModule :: FilePath -> IO (Either String [P.Module])
75loadModule moduleFile = do
75loadModule moduleFile = do
@@ -98,9 +98,7 @@ prologueMessage = intercalate "\n"
98quitMessage :: String
98quitMessage :: String
99quitMessage = "See ya!"
99quitMessage = "See ya!"
100
100
101−options :: P.Options
101+-- Haskeline completions
102−options = P.Options True False True (Just "Main") True "PS" []
103−
104completion :: [P.Module] -> CompletionFunc IO
102completion :: [P.Module] -> CompletionFunc IO
105completion ms = completeWord Nothing " \t\n\r" findCompletions
103completion ms = completeWord Nothing " \t\n\r" findCompletions
106 where
104 where
@@ -119,6 +117,10 @@ completion ms = completeWord Nothing " \t\n\r" findCompletions
119 getDeclName (P.ValueDeclaration ident _ _ _) = Just ident
117 getDeclName (P.ValueDeclaration ident _ _ _) = Just ident
120 getDeclName _ = Nothing
118 getDeclName _ = Nothing
121
119
120+-- Compilation
121+options :: P.Options
122+options = P.Options True False True (Just "Main") True "PS" []
123+
122createTemporaryModule :: [P.ProperName] -> [P.DoNotationElement] -> P.Value -> P.Module
124createTemporaryModule :: [P.ProperName] -> [P.DoNotationElement] -> P.Value -> P.Module
123createTemporaryModule imports binders value =
125createTemporaryModule imports binders value =
124 let
126 let
@@ -147,6 +149,7 @@ handleDeclaration value (PSCI imports loadedModules binders) = do
147 Just (ExitFailure _, _, err) -> outputStrLn err
149 Just (ExitFailure _, _, err) -> outputStrLn err
148 Nothing -> outputStrLn "Couldn't find node.js"
150 Nothing -> outputStrLn "Couldn't find node.js"
149
151
152+-- Parser helpers
150parseDoNotationLet :: Parsec.Parsec String P.ParseState P.DoNotationElement
153parseDoNotationLet :: Parsec.Parsec String P.ParseState P.DoNotationElement
151parseDoNotationLet = P.DoNotationLet <$> (P.reserved "let" *> P.indented *> P.parseBinder)
154parseDoNotationLet = P.DoNotationLet <$> (P.reserved "let" *> P.indented *> P.parseBinder)
152 <*> (P.indented *> P.reservedOp "=" *> P.parseValue)
155 <*> (P.indented *> P.reservedOp "=" *> P.parseValue)
@@ -157,6 +160,7 @@ parseDoNotationBind = P.DoNotationBind <$> P.parseBinder <*> (P.indented *> P.re
157parseExpression :: Parsec.Parsec String P.ParseState P.Value
160parseExpression :: Parsec.Parsec String P.ParseState P.Value
158parseExpression = P.whiteSpace *> P.parseValue <* Parsec.eof
161parseExpression = P.whiteSpace *> P.parseValue <* Parsec.eof
159
162
163+-- Commands
160handleCommand :: Command -> StateT PSCI (InputT IO) ()
164handleCommand :: Command -> StateT PSCI (InputT IO) ()
161handleCommand Empty = return ()
165handleCommand Empty = return ()
162handleCommand (Expression ls) =
166handleCommand (Expression ls) =