on master help sign in
Handle Ctrl-C
commit264f8a651463b0691fcd4b82caee643499672f4c authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateSat 7 Jan 2012, 20:34 (15 years ago) parent4ca34ff
1 file changed+10−6
src/Idris/REPL.hs+10−6
src/Idris/REPL.hs+10−6
@@ -32,18 +32,22 @@ import Data.Version
3232
3333repl :: IState -> [FilePath] -> Idris ()
3434repl orig mods
35− = do let prompt = mkPrompt mods
35+ = H.catch
36+ (do let prompt = mkPrompt mods
3637 x <- lift $ getInputLine (prompt ++ "> ")
3738 case x of
3839 Nothing -> do iputStrLn "Bye bye"
3940 return ()
40− Just input -> idrisCatch
41− (do ms <- processInput input orig mods
42− case ms of
41+ Just input -> H.catch
42+ (do ms <- processInput input orig mods
43+ case ms of
4344 Just mods -> repl orig mods
4445 Nothing -> return ())
45− (\e -> do iputStrLn (show e)
46− repl orig mods)
46+ ctrlC)
47+ ctrlC
48+ where ctrlC :: SomeException -> Idris ()
49+ ctrlC e = do iputStrLn (show e)
50+ repl orig mods
4751
4852mkPrompt [] = "Idris"
4953mkPrompt [x] = "*" ++ dropExtension x