Wolfgang Jeltsch pushed to branch wip/jeltsch/system-io-uncovering at Glasgow Haskell Compiler / GHC
Commits:
-
d4c75552
by Wolfgang Jeltsch at 2026-02-25T17:46:52+02:00
3 changed files:
- libraries/base/src/GHC/GHCi/Helpers.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- − libraries/ghc-internal/src/GHC/Internal/GHCi/Helpers.hs
Changes:
| 1 | -{-# LANGUAGE Safe #-}
|
|
| 1 | +{-# LANGUAGE Trustworthy #-}
|
|
| 2 | 2 | |
| 3 | 3 | -- |
|
| 4 | 4 | --
|
| ... | ... | @@ -24,4 +24,21 @@ module GHC.GHCi.Helpers |
| 24 | 24 | evalWrapper
|
| 25 | 25 | ) where
|
| 26 | 26 | |
| 27 | -import GHC.Internal.GHCi.Helpers |
|
| \ No newline at end of file | ||
| 27 | +import GHC.Internal.Base
|
|
| 28 | +import GHC.Internal.System.IO
|
|
| 29 | +import GHC.Internal.System.Environment
|
|
| 30 | + |
|
| 31 | +disableBuffering :: IO ()
|
|
| 32 | +disableBuffering = do
|
|
| 33 | + hSetBuffering stdin NoBuffering
|
|
| 34 | + hSetBuffering stdout NoBuffering
|
|
| 35 | + hSetBuffering stderr NoBuffering
|
|
| 36 | + |
|
| 37 | +flushAll :: IO ()
|
|
| 38 | +flushAll = do
|
|
| 39 | + hFlush stdout
|
|
| 40 | + hFlush stderr
|
|
| 41 | + |
|
| 42 | +evalWrapper :: String -> [String] -> IO a -> IO a
|
|
| 43 | +evalWrapper progName args m =
|
|
| 44 | + withProgName progName (withArgs args m) |
| ... | ... | @@ -228,7 +228,6 @@ Library |
| 228 | 228 | GHC.Internal.ForeignPtr
|
| 229 | 229 | GHC.Internal.Functor.ZipList
|
| 230 | 230 | GHC.Internal.GHCi
|
| 231 | - GHC.Internal.GHCi.Helpers
|
|
| 232 | 231 | GHC.Internal.Generics
|
| 233 | 232 | GHC.Internal.Heap.Closures
|
| 234 | 233 | GHC.Internal.Heap.Constants
|
| 1 | -{-# LANGUAGE Trustworthy #-}
|
|
| 2 | - |
|
| 3 | ------------------------------------------------------------------------------
|
|
| 4 | --- |
|
|
| 5 | --- Module : GHC.Internal.GHCi.Helpers
|
|
| 6 | --- Copyright : (c) The GHC Developers
|
|
| 7 | --- License : see libraries/base/LICENSE
|
|
| 8 | ---
|
|
| 9 | --- Maintainer : ghc-devs@haskell.org
|
|
| 10 | --- Stability : internal
|
|
| 11 | --- Portability : non-portable (GHC Extensions)
|
|
| 12 | ---
|
|
| 13 | --- Various helpers used by the GHCi shell.
|
|
| 14 | ---
|
|
| 15 | --- /The API of this module is unstable and not meant to be consumed by the general public./
|
|
| 16 | --- If you absolutely must depend on it, make sure to use a tight upper
|
|
| 17 | --- bound, e.g., @base < 4.X@ rather than @base < 5@, because the interface can
|
|
| 18 | --- change rapidly without much warning.
|
|
| 19 | ---
|
|
| 20 | ------------------------------------------------------------------------------
|
|
| 21 | - |
|
| 22 | -module GHC.Internal.GHCi.Helpers
|
|
| 23 | - ( disableBuffering, flushAll
|
|
| 24 | - , evalWrapper
|
|
| 25 | - ) where
|
|
| 26 | - |
|
| 27 | -import GHC.Internal.Base
|
|
| 28 | -import GHC.Internal.System.IO
|
|
| 29 | -import GHC.Internal.System.Environment
|
|
| 30 | - |
|
| 31 | -disableBuffering :: IO ()
|
|
| 32 | -disableBuffering = do
|
|
| 33 | - hSetBuffering stdin NoBuffering
|
|
| 34 | - hSetBuffering stdout NoBuffering
|
|
| 35 | - hSetBuffering stderr NoBuffering
|
|
| 36 | - |
|
| 37 | -flushAll :: IO ()
|
|
| 38 | -flushAll = do
|
|
| 39 | - hFlush stdout
|
|
| 40 | - hFlush stderr
|
|
| 41 | - |
|
| 42 | -evalWrapper :: String -> [String] -> IO a -> IO a
|
|
| 43 | -evalWrapper progName args m =
|
|
| 44 | - withProgName progName (withArgs args m) |