module Data.ByteString.Char8.SaferFileHandles
    ( hGetLine
    , hGetContents
    , hGet
    , hGetNonBlocking
    , hPut
    , hPutStr
    , hPutStrLn
    ) where
import Data.Int ( Int )
import Control.Monad.IO.Class ( MonadIO )
import qualified Data.ByteString.Char8 as B
import Control.Monad.Trans.Region ( AncestorRegion )
import qualified Data.ByteString.Char8.ExplicitIOModes as E ( hGetLine
                                                            , hGetContents
                                                            , hGet
                                                            , hGetNonBlocking
                                                            , hPut
                                                            , hPutStr
                                                            , hPutStrLn
                                                            )
import System.IO.SaferFileHandles        ( FileHandle, ReadModes, WriteModes )
import System.IO.SaferFileHandles.Unsafe ( wrap, wrap2 )
hGetLine ∷ ( FileHandle handle, ReadModes ioMode
           , pr `AncestorRegion` cr, MonadIO cr
           )
         ⇒ handle ioMode pr → cr B.ByteString
hGetLine = wrap E.hGetLine
hGetContents ∷ ( FileHandle handle, ReadModes ioMode
               , pr `AncestorRegion` cr, MonadIO cr
               )
             ⇒ handle ioMode pr → cr B.ByteString
hGetContents = wrap E.hGetContents
hGet ∷ ( FileHandle handle, ReadModes ioMode
       , pr `AncestorRegion` cr, MonadIO cr
       )
     ⇒ handle ioMode pr → Int → cr B.ByteString
hGet = wrap2 E.hGet
hGetNonBlocking ∷ ( FileHandle handle, ReadModes ioMode
                  , pr `AncestorRegion` cr, MonadIO cr
                  )
                ⇒ handle ioMode pr → Int → cr B.ByteString
hGetNonBlocking = wrap2 E.hGetNonBlocking
hPut ∷ ( FileHandle handle, WriteModes ioMode
       , pr `AncestorRegion` cr, MonadIO cr
       )
     ⇒ handle ioMode pr → B.ByteString → cr ()
hPut = wrap2 E.hPut
hPutStr ∷ ( FileHandle handle, WriteModes ioMode
          , pr `AncestorRegion` cr, MonadIO cr
          )
        ⇒ handle ioMode pr → B.ByteString → cr ()
hPutStr = wrap2 E.hPutStr
hPutStrLn ∷ ( FileHandle handle, WriteModes ioMode
            , pr `AncestorRegion` cr, MonadIO cr
            )
          ⇒ handle ioMode pr → B.ByteString → cr ()
hPutStrLn = wrap2 E.hPutStrLn