git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Ghci-like handling of Ctrl-C, Ctrl-D in psci
e3177bfKonstantin Zudov
psci/PSCi.hs+3−3
@@ -437,10 +437,10 @@ handleKindOf typ = do
437-- Parses the input and returns either a Metacommand, or an error as a string.
437-- Parses the input and returns either a Metacommand, or an error as a string.
438--
438--
439getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))
439getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))
440−getCommand singleLineMode = do
440+getCommand singleLineMode = handleInterrupt (return (Right Nothing)) $ do
441− firstLine <- getInputLine "> "
441+ firstLine <- withInterrupt $ getInputLine "> "
442 case firstLine of
442 case firstLine of
443− Nothing -> return (Right Nothing)
443+ Nothing -> return (Right (Just QuitPSCi)) -- Ctrl-D when input is empty
444 Just "" -> return (Right Nothing)
444 Just "" -> return (Right Nothing)
445 Just s | singleLineMode || head s == ':' -> return . either Left (Right . Just) $ parseCommand s
445 Just s | singleLineMode || head s == ':' -> return . either Left (Right . Just) $ parseCommand s
446 Just s -> either Left (Right . Just) . parseCommand <$> go [s]
446 Just s -> either Left (Right . Just) . parseCommand <$> go [s]