on master help sign in
Handle Ctrl-C
264f8a6Edwin Brady
src/Idris/REPL.hs+10−6
@@ -32,18 +32,22 @@ import Data.Version
32
32
33repl :: IState -> [FilePath] -> Idris ()
33repl :: IState -> [FilePath] -> Idris ()
34repl orig mods
34repl orig mods
35+ = H.catch
35− = do let prompt = mkPrompt mods
36+ (do let prompt = mkPrompt mods
36 x <- lift $ getInputLine (prompt ++ "> ")
37 x <- lift $ getInputLine (prompt ++ "> ")
37 case x of
38 case x of
38 Nothing -> do iputStrLn "Bye bye"
39 Nothing -> do iputStrLn "Bye bye"
39 return ()
40 return ()
40− Just input -> idrisCatch
41+ Just input -> H.catch
41− (do ms <- processInput input orig mods
42+ (do ms <- processInput input orig mods
42− case ms of
43+ case ms of
43 Just mods -> repl orig mods
44 Just mods -> repl orig mods
44 Nothing -> return ())
45 Nothing -> return ())
46+ ctrlC)
47+ ctrlC
48+ where ctrlC :: SomeException -> Idris ()
45− (\e -> do iputStrLn (show e)
49+ ctrlC e = do iputStrLn (show e)
46− repl orig mods)
50+ repl orig mods
47
51
48mkPrompt [] = "Idris"
52mkPrompt [] = "Idris"
49mkPrompt [x] = "*" ++ dropExtension x
53mkPrompt [x] = "*" ++ dropExtension x