-----------------------------------------------------------------------------
-- |
-- Module      :  GHC.GHCi.Helpers
-- Copyright   :  (c) The GHC Developers
-- License     :  see libraries/base/LICENSE
--
-- Maintainer  :  cvs-ghc@haskell.org
-- Stability   :  internal
-- Portability :  non-portable (GHC Extensions)
--
-- Various helpers used by the GHCi shell.
--
-----------------------------------------------------------------------------

module GHC.GHCi.Helpers
  ( disableBuffering, flushAll
  , evalWrapper
  ) where

import System.IO
import System.Environment

disableBuffering :: IO ()
disableBuffering :: IO ()
disableBuffering = do
  Handle -> BufferMode -> IO ()
hSetBuffering Handle
stdin BufferMode
NoBuffering
  Handle -> BufferMode -> IO ()
hSetBuffering Handle
stdout BufferMode
NoBuffering
  Handle -> BufferMode -> IO ()
hSetBuffering Handle
stderr BufferMode
NoBuffering

flushAll :: IO ()
flushAll :: IO ()
flushAll = do
  Handle -> IO ()
hFlush Handle
stdout
  Handle -> IO ()
hFlush Handle
stderr

evalWrapper :: String -> [String] -> IO a -> IO a
evalWrapper :: String -> [String] -> IO a -> IO a
evalWrapper String
progName [String]
args IO a
m =
  String -> IO a -> IO a
forall a. String -> IO a -> IO a
withProgName String
progName ([String] -> IO a -> IO a
forall a. [String] -> IO a -> IO a
withArgs [String]
args IO a
m)