module UnliftIO.IO
( IOMode (..)
, Handle
, IO.stdin
, IO.stdout
, IO.stderr
, withFile
, withBinaryFile
, hClose
, hFlush
, hFileSize
, hSetFileSize
, hIsEOF
, IO.BufferMode (..)
, hSetBuffering
, hGetBuffering
, hSeek
, IO.SeekMode (..)
, hTell
, hIsOpen
, hIsClosed
, hIsReadable
, hIsWritable
, hIsSeekable
, hIsTerminalDevice
, hSetEcho
, hGetEcho
, hWaitForInput
, hReady
, getMonotonicTime
) where
import qualified System.IO as IO
import System.IO (Handle, IOMode (..))
import Control.Monad.IO.Unlift
import System.IO.Unsafe (unsafePerformIO)
withFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a
withFile fp mode inner = withRunInIO $ \run -> IO.withFile fp mode $ run . inner
withBinaryFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a
withBinaryFile fp mode inner = withRunInIO $ \run -> IO.withBinaryFile fp mode $ run . inner
hClose :: MonadIO m => Handle -> m ()
hClose = liftIO . IO.hClose
hFlush :: MonadIO m => Handle -> m ()
hFlush = liftIO . IO.hFlush
hFileSize :: MonadIO m => Handle -> m Integer
hFileSize = liftIO . IO.hFileSize
hSetFileSize :: MonadIO m => Handle -> Integer -> m ()
hSetFileSize h = liftIO . IO.hSetFileSize h
hIsEOF :: MonadIO m => Handle -> m Bool
hIsEOF = liftIO . IO.hIsEOF
hSetBuffering :: MonadIO m => Handle -> IO.BufferMode -> m ()
hSetBuffering h = liftIO . IO.hSetBuffering h
hGetBuffering :: MonadIO m => Handle -> m IO.BufferMode
hGetBuffering = liftIO . IO.hGetBuffering
hSeek :: MonadIO m => Handle -> IO.SeekMode -> Integer -> m ()
hSeek h s = liftIO . IO.hSeek h s
hTell :: MonadIO m => Handle -> m Integer
hTell = liftIO . IO.hTell
hIsOpen :: MonadIO m => Handle -> m Bool
hIsOpen = liftIO . IO.hIsOpen
hIsClosed :: MonadIO m => Handle -> m Bool
hIsClosed = liftIO . IO.hIsClosed
hIsReadable :: MonadIO m => Handle -> m Bool
hIsReadable = liftIO . IO.hIsReadable
hIsWritable :: MonadIO m => Handle -> m Bool
hIsWritable = liftIO . IO.hIsWritable
hIsSeekable :: MonadIO m => Handle -> m Bool
hIsSeekable = liftIO . IO.hIsSeekable
hIsTerminalDevice :: MonadIO m => Handle -> m Bool
hIsTerminalDevice = liftIO . IO.hIsTerminalDevice
hSetEcho :: MonadIO m => Handle -> Bool -> m ()
hSetEcho h = liftIO . IO.hSetEcho h
hGetEcho :: MonadIO m => Handle -> m Bool
hGetEcho = liftIO . IO.hGetEcho
hWaitForInput :: MonadIO m => Handle -> Int -> m Bool
hWaitForInput h = liftIO . IO.hWaitForInput h
hReady :: MonadIO m => Handle -> m Bool
hReady = liftIO . IO.hReady
getMonotonicTime :: MonadIO m => m Double
getMonotonicTime = liftIO $ initted `seq` getMonotonicTime'
foreign import ccall unsafe "unliftio_inittime" initializeTime :: IO ()
initted :: ()
initted = unsafePerformIO initializeTime
{-# NOINLINE initted #-}
foreign import ccall unsafe "unliftio_gettime" getMonotonicTime' :: IO Double