C-Ausnahmefang bei GHC (Haskell)

Ich habe in Haskell eine wirklich einfache Lese-Auswertungs-Druck-Schleife erstellt, die Control-C (UserInterrupt) abfängt. Wenn ich dieses Programm kompiliere und ausführe, fängt es jedoch immer das erste Control-C ab und bricht beim zweiten Control-C immer mit dem Exit-Code 130 ab. Es spielt keine Rolle, wie viele Eingabezeilen ich vor und zwischen den beiden gebe Control-Cs, es passiert immer so. Ich weiß, ich muss etwas Einfaches vermissen ... bitte helfen Sie, danke!

Hinweis: Dies gilt mit Base-4-Ausnahmen, also mit Control.Exception und nicht mit Control.OldException.

import Control.Exception as E
import System.IO

main :: IO ()
main = do hSetBuffering stdout NoBuffering
          hSetBuffering stdin NoBuffering
          repLoop

repLoop :: IO ()
repLoop
  = do putStr "> "
       line <- interruptible "<interrupted>" getLine
       if line == "exit"
          then putStrLn "goodbye"
          else do putStrLn $ "input was: " ++ line
                  repLoop

interruptible :: a -> IO a -> IO a
interruptible a m
  = E.handleJust f return m
  where
    f UserInterrupt
      = Just a
    f _
      = Nothing

Antworten auf die Frage(3)

Ihre Antwort auf die Frage