codegen: handle exceptions of a method
[mate.git] / Mate / Debug.hs
index 7acd3cd34abc3270d15f57a5f7aa7a06b731db1a..ba7ce315722e82be962d7d1543ff14780f328509 100644 (file)
@@ -14,6 +14,7 @@ module Mate.Debug
 import Text.Printf
 import System.IO
 import System.IO.Unsafe
+import Control.Monad
 
 
 {-# NOINLINE logHandle #-}
@@ -27,10 +28,9 @@ mateDEBUG = False
 
 {-# INLINE printString #-}
 printString :: String -> String -> IO ()
-printString prefix str = if mateDEBUG
-  then hPutStr logHandle . (++) prefix $ str
-  else return ()
-
+printString prefix str = do
+  when mateDEBUG $ hPutStr logHandle . (++) prefix $ str
+  hFlush logHandle
 
 printfJit, printfBb, printfMp, printfCp, printfStr, printfInfo  :: String -> IO ()
 {-