module Test.Framework.Runners.Console.Utilities ( hideCursorDuring ) where import System.Console.ANSI ( hideCursor, showCursor ) import System.IO ( hFlush, stdout ) import Control.Exception (bracket) hideCursorDuring :: IO a -> IO a hideCursorDuring :: forall a. IO a -> IO a hideCursorDuring IO a action = IO () -> (() -> IO ()) -> (() -> IO a) -> IO a forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c bracket IO () hideCursor (IO () -> () -> IO () forall a b. a -> b -> a const (IO () showCursor IO () -> IO () -> IO () forall a b. IO a -> IO b -> IO b forall (m :: * -> *) a b. Monad m => m a -> m b -> m b >> Handle -> IO () hFlush Handle stdout)) (IO a -> () -> IO a forall a b. a -> b -> a const IO a action)