git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add a :s command to list the modules loaded in current session.
commit84cf4dcb7c002a6d4001159dc6def281101c70e2 authorAntoine R. Dumont <antoine.romain.dumont@gmail.com> dateFri 31 Oct 2014, 13:14 (12 years ago) parent358a763
3 files changed+20−1
psci/Commands.hs+5 psci/Main.hs+9 psci/Parser.hs+6−1
psci/Commands.hs+5
@@ -61,6 +61,10 @@ data Command
6161 -- Find the kind of an expression
6262 --
6363 | KindOf Type
64+ -- |
65+ -- Show command
66+ --
67+ | Show
6468
6569-- |
6670-- The help menu.
@@ -75,4 +79,5 @@ help =
7579 , [":r ", "Reset"]
7680 , [":t <expr> ", "Show the type of <expr>"]
7781 , [":k <type> ", "Show the kind of <type>"]
82+ , [":s ", "Show loaded modules" ]
7883 ]
psci/Main.hs+9
@@ -305,6 +305,14 @@ handleDeclaration value = do
305305 Just (ExitFailure _, _, err) -> PSCI $ outputStrLn err
306306 Nothing -> PSCI $ outputStrLn "Couldn't find node.js"
307307
308+handleShowModules :: PSCI ()
309+handleShowModules = do
310+ PSCiState { psciLoadedModules = loadedModules } <- PSCI $ lift get
311+ psciIO $ readModules loadedModules >>= putStrLn
312+ return ()
313+ where readModules = return . unlines . nub . map toModuleName
314+ toModuleName = N.runModuleName . (\ (D.Module mdName _ _) -> mdName) . snd
315+
308316-- |
309317-- Imports a module, preserving the initial state on failure.
310318--
@@ -447,6 +455,7 @@ handleCommand Reset = do
447455handleCommand (TypeOf val) = handleTypeOf val
448456handleCommand (KindOf typ) = handleKindOf typ
449457handleCommand (Browse moduleName) = handleBrowse moduleName
458+handleCommand Show = handleShowModules
450459handleCommand _ = PSCI $ outputStrLn "Unknown command"
451460
452461singleLineFlag :: Cmd.Term Bool
psci/Parser.hs+6−1
@@ -42,7 +42,7 @@ psciLet = Let <$> (P.Let <$> (P.reserved "let" *> P.indented *> C.mark (many1 (C
4242--
4343parseCommand :: String -> Either ParseError Command
4444parseCommand = P.runIndentParser "" $ choice
45− [ P.whiteSpace *> char ':' *> (psciHelp <|> psciImport <|> psciLoadFile <|> psciQuit <|> psciReload <|> psciTypeOf <|> psciKindOf <|> psciBrowse)
45+ [ P.whiteSpace *> char ':' *> (psciHelp <|> psciImport <|> psciLoadFile <|> psciQuit <|> psciReload <|> psciTypeOf <|> psciKindOf <|> psciBrowse <|> psciShowModules)
4646 , try psciLet
4747 , psciExpression
4848 ] <* eof
@@ -103,3 +103,8 @@ psciKindOf = KindOf <$> (char 'k' *> P.whiteSpace *> P.parseType)
103103--
104104psciBrowse :: Parsec String P.ParseState Command
105105psciBrowse = Browse <$> (char 'b' *> P.whiteSpace *> P.moduleName)
106+
107+-- |
108+-- Show Command
109+psciShowModules :: Parsec String P.ParseState Command
110+psciShowModules = Show <$ char 's'