aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-09-12 11:57:54 +0200
committerTom Smeding <tom@tomsmeding.com>2023-09-12 11:57:54 +0200
commite7a3680052a9b3ef206af4cd934b6a0d61ffb7ad (patch)
tree9abbc53c8af4beb51386c89b21463ff13b6670e1
parentb8ccd25b6917a720c0b68479c976f18bc324922d (diff)
Separate reply message for :q
-rw-r--r--src/Ghci.hs4
-rw-r--r--src/Main.hs2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/Ghci.hs b/src/Ghci.hs
index ae44881..85081c5 100644
--- a/src/Ghci.hs
+++ b/src/Ghci.hs
@@ -61,7 +61,7 @@ parseSettingsReply = ParseSettings 200 True
parseSettingsPaste :: ParseSettings
parseSettingsPaste = ParseSettings 50000 False
-data Result a = Error String | Ignored | Return a
+data Result a = Error String | Ignored | Return a | Exited
deriving (Show)
makeGhci :: IO Ghci
@@ -95,7 +95,7 @@ runStmtClever ghci pset line =
putStrLn "ghci: restarting due to :quit"
hFlush stdout
ghci' <- makeGhci
- return (ghci', Return "")
+ return (ghci', Exited)
_ -> runStmt ghci pset line
_ -> runStmt ghci pset line
where
diff --git a/src/Main.hs b/src/Main.hs
index 8990efb..89e27d7 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -102,6 +102,7 @@ runInGhci ghci pset message = do
Ignored -> return (ghci', Nothing)
Return "" -> return (ghci', Just (T.pack "<no output>"))
Return s -> return (ghci', Just (T.pack s))
+ Exited -> return (ghci', Just (T.pack "<bye>"))
data ReqKind = Reply | Paste
deriving (Show)
@@ -141,6 +142,7 @@ mainGHCI = do
Return output -> putStrLn $ "output = <" ++ output ++ ">"
Ignored -> putStrLn "<ignored>"
Error err -> putStrLn err
+ Exited -> putStrLn $ "<exited>"
loop ghci'
makeGhci >>= loop