module GHC.IO.SubSystem (
withIoSubSystem,
withIoSubSystem',
whenIoSubSystem,
ioSubSystem,
IoSubSystem(..),
conditional,
(<!>),
isWindowsNativeIO
) where
import GHC.Base
import GHC.RTS.Flags
#if defined(mingw32_HOST_OS)
import GHC.IO.Unsafe
#endif
infixl 7 <!>
conditional :: a -> a -> a
#if defined(mingw32_HOST_OS)
conditional posix windows =
case ioSubSystem of
IoPOSIX -> posix
IoNative -> windows
#else
conditional posix _ = posix
#endif
(<!>) :: a -> a -> a
(<!>) = conditional
isWindowsNativeIO :: Bool
isWindowsNativeIO = False <!> True
ioSubSystem :: IoSubSystem
#if defined(mingw32_HOST_OS)
ioSubSystem = unsafeDupablePerformIO getIoManagerFlag
#else
ioSubSystem = IoPOSIX
#endif
withIoSubSystem :: (IoSubSystem -> IO a) -> IO a
withIoSubSystem f = f ioSubSystem
withIoSubSystem' :: (IoSubSystem -> a) -> a
withIoSubSystem' f = f ioSubSystem
whenIoSubSystem :: IoSubSystem -> IO () -> IO ()
whenIoSubSystem m f = do let sub = ioSubSystem
when (sub == m) f