module HaskellWorks.Polysemy.System.IO
  ( IO.BufferMode(..),
    IO.FilePath,
    IO.Handle,
    IO.HandlePosn,
    IO.IO,
    IO.IOMode(..),
    IO.NewlineMode(..),
    IO.SeekMode(..),
    IO.TextEncoding,

    String,

    IO.stdin,
    IO.stdout,
    IO.stderr,

    withFile,
    hClose,
    openFile,
    readFile,
    appendFile,
    writeFile,
    hFileSize,
    hSetFileSize,
    hIsEOF,
    isEOF,
    hSetBuffering,
    hGetBuffering,
    hFlush,
    hGetPosn,
    hSetPosn,
    hSeek,
    hTell,
    hIsOpen,
    hIsClosed,
    hIsReadable,
    hIsWritable,
    hIsSeekable,
    hIsTerminalDevice,
    hSetEcho,
    hGetEcho,
    hShow,
    hWaitForInput,
    hReady,
    hGetChar,
    hGetLine,
    hLookAhead,
    hGetContents,
    hGetContents',
    hPutChar,
    hPutStr,
    hPutStrLn,
    hPrint,

    interact,
    putChar,
    putStr,
    putStrLn,
    print,
    getChar,
    getLine,
    getContents,
    getContents',
    readIO,
    readLn,

    withBinaryFile,
    openBinaryFile,

    hPutBuf,
    hGetBuf,
    hGetBufSome,
    hPutBufNonBlocking,
    hGetBufNonBlocking,
    openTempFile,
    openBinaryTempFile,
    openTempFileWithDefaultPermissions,
    openBinaryTempFileWithDefaultPermissions,
    hSetEncoding,
    hGetEncoding,

    IO.latin1,
    IO.utf8,
    IO.utf8_bom,
    IO.utf16,
    IO.utf16le,
    IO.utf16be,
    IO.utf32,
    IO.utf32le,
    IO.utf32be,
    IO.localeEncoding,
    IO.char8,

    mkTextEncoding,
    hSetNewlineMode,

    IO.nativeNewline,
    IO.noNewlineTranslation,
    IO.universalNewlineMode,
    IO.nativeNewlineMode,
  ) where

import qualified Control.Exception             as CE
import qualified Data.Text                     as Text
import           Foreign.Ptr                   (Ptr)
import qualified GHC.Stack                     as GHC
import           HaskellWorks.Polysemy.Prelude
import qualified System.IO                     as IO
import           System.IO                     (BufferMode, Handle, HandlePosn,
                                                IOMode, NewlineMode, SeekMode,
                                                TextEncoding)
import           Text.Read

import           Polysemy
import           Polysemy.Error
import           Polysemy.Log
import           Polysemy.Resource

-- | Open a file handle and run an action, closing the handle when done.
withFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Resource r
  => Member Log r
  => FilePath
  -> IOMode
  -> (Handle -> Sem r a)
  -> Sem r a
withFile :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Resource r, Member Log r) =>
FilePath -> IOMode -> (Handle -> Sem r a) -> Sem r a
withFile FilePath
fp IOMode
mode Handle -> Sem r a
f = (HasCallStack => Sem r a) -> Sem r a
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r a) -> Sem r a)
-> (HasCallStack => Sem r a) -> Sem r a
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Calling: withFile " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
forall a. Show a => a -> Text
tshow FilePath
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> IOMode -> Text
forall a. Show a => a -> Text
tshow IOMode
mode

  Sem r Handle
-> (Handle -> Sem r ()) -> (Handle -> Sem r a) -> Sem r a
forall (r :: EffectRow) a c b.
Member Resource r =>
Sem r a -> (a -> Sem r c) -> (a -> Sem r b) -> Sem r b
bracket (FilePath -> IOMode -> Sem r Handle
forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> IOMode -> Sem r Handle
openFile FilePath
fp IOMode
mode) Handle -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r ()
hClose Handle -> Sem r a
f

-- | Open a file handle and run an action, closing the handle when done.
withBinaryFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Resource r
  => Member Log r
  => FilePath
  -> IOMode
  -> (Handle -> Sem r a)
  -> Sem r a
withBinaryFile :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Resource r, Member Log r) =>
FilePath -> IOMode -> (Handle -> Sem r a) -> Sem r a
withBinaryFile FilePath
fp IOMode
mode Handle -> Sem r a
f = (HasCallStack => Sem r a) -> Sem r a
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r a) -> Sem r a)
-> (HasCallStack => Sem r a) -> Sem r a
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Calling: withBinaryFile " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
forall a. Show a => a -> Text
tshow FilePath
fp Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> IOMode -> Text
forall a. Show a => a -> Text
tshow IOMode
mode

  Sem r Handle
-> (Handle -> Sem r ()) -> (Handle -> Sem r a) -> Sem r a
forall (r :: EffectRow) a c b.
Member Resource r =>
Sem r a -> (a -> Sem r c) -> (a -> Sem r b) -> Sem r b
bracket (FilePath -> IOMode -> Sem r Handle
forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> IOMode -> Sem r Handle
openBinaryFile FilePath
fp IOMode
mode) Handle -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r ()
hClose Handle -> Sem r a
f

-- | Open a file handle.
openFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> IOMode
  -> Sem r Handle
openFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> IOMode -> Sem r Handle
openFile FilePath
fp IOMode
mode = (HasCallStack => Sem r Handle) -> Sem r Handle
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Handle) -> Sem r Handle)
-> (HasCallStack => Sem r Handle) -> Sem r Handle
forall a b. (a -> b) -> a -> b
$ do
  Either IOException Handle
r <- IO (Either IOException Handle) -> Sem r (Either IOException Handle)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (IO (Either IOException Handle)
 -> Sem r (Either IOException Handle))
-> IO (Either IOException Handle)
-> Sem r (Either IOException Handle)
forall a b. (a -> b) -> a -> b
$ forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Handle -> IO (Either IOException Handle))
-> IO Handle -> IO (Either IOException Handle)
forall a b. (a -> b) -> a -> b
$ FilePath -> IOMode -> IO Handle
IO.openFile FilePath
fp IOMode
mode
  case Either IOException Handle
r of
    Left IOException
e  -> do
      Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
error (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Failed to open file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
      IOException -> Sem r Handle
forall e (r :: EffectRow) a. Member (Error e) r => e -> Sem r a
throw IOException
e
    Right Handle
h -> do
      Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Opened file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
      Handle -> Sem r Handle
forall a. a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Handle
h

-- | Open a file handle.
openBinaryFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> IOMode
  -> Sem r Handle
openBinaryFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> IOMode -> Sem r Handle
openBinaryFile FilePath
fp IOMode
mode = (HasCallStack => Sem r Handle) -> Sem r Handle
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Handle) -> Sem r Handle)
-> (HasCallStack => Sem r Handle) -> Sem r Handle
forall a b. (a -> b) -> a -> b
$ do
  Either IOException Handle
r <- IO (Either IOException Handle) -> Sem r (Either IOException Handle)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (IO (Either IOException Handle)
 -> Sem r (Either IOException Handle))
-> IO (Either IOException Handle)
-> Sem r (Either IOException Handle)
forall a b. (a -> b) -> a -> b
$ forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Handle -> IO (Either IOException Handle))
-> IO Handle -> IO (Either IOException Handle)
forall a b. (a -> b) -> a -> b
$ FilePath -> IOMode -> IO Handle
IO.openBinaryFile FilePath
fp IOMode
mode
  case Either IOException Handle
r of
    Left IOException
e  -> do
      Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
error (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Failed to open file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
      IOException -> Sem r Handle
forall e (r :: EffectRow) a. Member (Error e) r => e -> Sem r a
throw IOException
e
    Right Handle
h -> do
      Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Opened file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
      Handle -> Sem r Handle
forall a. a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Handle
h

-- | Close the file handle.
hClose :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r ()
hClose :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r ()
hClose Handle
h = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Closing file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Handle -> Text
forall a. Show a => a -> Text
tshow Handle
h
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> IO ()
IO.hClose Handle
h)

-- | Read a file as a string.
readFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> Sem r String
readFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> Sem r FilePath
readFile FilePath
filePath = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Reading string file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
filePath
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO FilePath -> IO (Either IOException FilePath))
-> IO FilePath -> IO (Either IOException FilePath)
forall a b. (a -> b) -> a -> b
$ FilePath -> IO FilePath
IO.readFile FilePath
filePath)

writeFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r ()
writeFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r ()
writeFile FilePath
fp FilePath
contents = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Write string to file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO ()
IO.writeFile FilePath
fp FilePath
contents)

appendFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r ()
appendFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r ()
appendFile FilePath
fp FilePath
contents = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Append string to file: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FilePath -> Text
Text.pack FilePath
fp
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO ()
IO.appendFile FilePath
fp FilePath
contents)

hFileSize :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Integer
hFileSize :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Integer
hFileSize Handle
h = (HasCallStack => Sem r Integer) -> Sem r Integer
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Integer) -> Sem r Integer)
-> (HasCallStack => Sem r Integer) -> Sem r Integer
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Called hFileSize: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Handle -> Text
forall a. Show a => a -> Text
tshow Handle
h
  Either IOException Integer -> Sem r Integer
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Integer -> Sem r Integer)
-> Sem r (Either IOException Integer) -> Sem r Integer
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Integer)
-> Sem r (Either IOException Integer)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Integer -> IO (Either IOException Integer))
-> IO Integer -> IO (Either IOException Integer)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Integer
IO.hFileSize Handle
h)

hSetFileSize :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Integer
  -> Sem r ()
hSetFileSize :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Integer -> Sem r ()
hSetFileSize Handle
h Integer
n = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Called hSetFileSize: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Handle -> Text
forall a. Show a => a -> Text
tshow Handle
h Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Integer -> Text
forall a. Show a => a -> Text
tshow Integer
n
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> Integer -> IO ()
IO.hSetFileSize Handle
h Integer
n)

hIsEOF :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsEOF :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsEOF Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
info (Text -> Sem r ()) -> Text -> Sem r ()
forall a b. (a -> b) -> a -> b
$ Text
"Called hIsEOF: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Handle -> Text
forall a. Show a => a -> Text
tshow Handle
h
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsEOF Handle
h)

isEOF :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r Bool
isEOF :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Sem r Bool
isEOF = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called isEOF"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO Bool
IO.isEOF)

hSetBuffering :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> BufferMode
  -> Sem r ()
hSetBuffering :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> BufferMode -> Sem r ()
hSetBuffering Handle
h BufferMode
bufferMode = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSetBuffering"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> BufferMode -> IO ()
IO.hSetBuffering Handle
h BufferMode
bufferMode)

hGetBuffering :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r BufferMode
hGetBuffering :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r BufferMode
hGetBuffering Handle
h = (HasCallStack => Sem r BufferMode) -> Sem r BufferMode
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r BufferMode) -> Sem r BufferMode)
-> (HasCallStack => Sem r BufferMode) -> Sem r BufferMode
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBuffering"
  Either IOException BufferMode -> Sem r BufferMode
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException BufferMode -> Sem r BufferMode)
-> Sem r (Either IOException BufferMode) -> Sem r BufferMode
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException BufferMode)
-> Sem r (Either IOException BufferMode)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO BufferMode -> IO (Either IOException BufferMode))
-> IO BufferMode -> IO (Either IOException BufferMode)
forall a b. (a -> b) -> a -> b
$ Handle -> IO BufferMode
IO.hGetBuffering Handle
h)

hFlush :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r ()
hFlush :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r ()
hFlush Handle
h = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hFlush"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> IO ()
IO.hFlush Handle
h)

hGetPosn :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r HandlePosn
hGetPosn :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r HandlePosn
hGetPosn Handle
h = (HasCallStack => Sem r HandlePosn) -> Sem r HandlePosn
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r HandlePosn) -> Sem r HandlePosn)
-> (HasCallStack => Sem r HandlePosn) -> Sem r HandlePosn
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetPosn"
  Either IOException HandlePosn -> Sem r HandlePosn
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException HandlePosn -> Sem r HandlePosn)
-> Sem r (Either IOException HandlePosn) -> Sem r HandlePosn
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException HandlePosn)
-> Sem r (Either IOException HandlePosn)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO HandlePosn -> IO (Either IOException HandlePosn))
-> IO HandlePosn -> IO (Either IOException HandlePosn)
forall a b. (a -> b) -> a -> b
$ Handle -> IO HandlePosn
IO.hGetPosn Handle
h)

hSetPosn :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => HandlePosn
  -> Sem r ()
hSetPosn :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
HandlePosn -> Sem r ()
hSetPosn HandlePosn
hPosn = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSetPosn"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ HandlePosn -> IO ()
IO.hSetPosn HandlePosn
hPosn)

hSeek :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> SeekMode
  -> Integer
  -> Sem r ()
hSeek :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> SeekMode -> Integer -> Sem r ()
hSeek Handle
h SeekMode
seekMode Integer
n = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSeek"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> SeekMode -> Integer -> IO ()
IO.hSeek Handle
h SeekMode
seekMode Integer
n)

hTell :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Integer
hTell :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Integer
hTell Handle
h = (HasCallStack => Sem r Integer) -> Sem r Integer
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Integer) -> Sem r Integer)
-> (HasCallStack => Sem r Integer) -> Sem r Integer
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBuffering"
  Either IOException Integer -> Sem r Integer
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Integer -> Sem r Integer)
-> Sem r (Either IOException Integer) -> Sem r Integer
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Integer)
-> Sem r (Either IOException Integer)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Integer -> IO (Either IOException Integer))
-> IO Integer -> IO (Either IOException Integer)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Integer
IO.hTell Handle
h)

hIsOpen :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsOpen :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsOpen Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsOpen"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsOpen Handle
h)

hIsClosed :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsClosed :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsClosed Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsClosed"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsClosed Handle
h)

hIsReadable :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsReadable :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsReadable Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsReadable"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsReadable Handle
h)

hIsWritable :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsWritable :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsWritable Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsWritable"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsWritable Handle
h)

hIsSeekable :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsSeekable :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsSeekable Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsSeekable"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsSeekable Handle
h)

hIsTerminalDevice :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hIsTerminalDevice :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hIsTerminalDevice Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hIsTerminalDevice"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hIsTerminalDevice Handle
h)

hSetEcho :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Bool
  -> Sem r ()
hSetEcho :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Bool -> Sem r ()
hSetEcho Handle
h Bool
v = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSetEcho"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> Bool -> IO ()
IO.hSetEcho Handle
h Bool
v)

hGetEcho :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hGetEcho :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hGetEcho Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBuffering"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hGetEcho Handle
h)

hShow :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r String
hShow :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r FilePath
hShow Handle
h = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hShow"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO FilePath -> IO (Either IOException FilePath))
-> IO FilePath -> IO (Either IOException FilePath)
forall a b. (a -> b) -> a -> b
$ Handle -> IO FilePath
IO.hShow Handle
h)

hWaitForInput :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Int
  -> Sem r Bool
hWaitForInput :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Int -> Sem r Bool
hWaitForInput Handle
h Int
n = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hWaitForInput"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> Int -> IO Bool
IO.hWaitForInput Handle
h Int
n)

hReady :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Bool
hReady :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Bool
hReady Handle
h = (HasCallStack => Sem r Bool) -> Sem r Bool
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Bool) -> Sem r Bool)
-> (HasCallStack => Sem r Bool) -> Sem r Bool
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hReady"
  Either IOException Bool -> Sem r Bool
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Bool -> Sem r Bool)
-> Sem r (Either IOException Bool) -> Sem r Bool
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Bool) -> Sem r (Either IOException Bool)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Bool -> IO (Either IOException Bool))
-> IO Bool -> IO (Either IOException Bool)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Bool
IO.hReady Handle
h)

hGetChar :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Char
hGetChar :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Char
hGetChar Handle
h = (HasCallStack => Sem r Char) -> Sem r Char
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Char) -> Sem r Char)
-> (HasCallStack => Sem r Char) -> Sem r Char
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetChar"
  Either IOException Char -> Sem r Char
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Char -> Sem r Char)
-> Sem r (Either IOException Char) -> Sem r Char
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Char) -> Sem r (Either IOException Char)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Char -> IO (Either IOException Char))
-> IO Char -> IO (Either IOException Char)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Char
IO.hGetChar Handle
h)

hGetLine :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r String
hGetLine :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r FilePath
hGetLine Handle
h = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetLine"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO FilePath -> IO (Either IOException FilePath))
-> IO FilePath -> IO (Either IOException FilePath)
forall a b. (a -> b) -> a -> b
$ Handle -> IO FilePath
IO.hGetLine Handle
h)

hLookAhead :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r Char
hLookAhead :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r Char
hLookAhead Handle
h = (HasCallStack => Sem r Char) -> Sem r Char
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Char) -> Sem r Char)
-> (HasCallStack => Sem r Char) -> Sem r Char
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hLookAhead"
  Either IOException Char -> Sem r Char
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Char -> Sem r Char)
-> Sem r (Either IOException Char) -> Sem r Char
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Char) -> Sem r (Either IOException Char)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Char -> IO (Either IOException Char))
-> IO Char -> IO (Either IOException Char)
forall a b. (a -> b) -> a -> b
$ Handle -> IO Char
IO.hLookAhead Handle
h)

hGetContents :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r String
hGetContents :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r FilePath
hGetContents Handle
h = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetContents"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO FilePath -> IO (Either IOException FilePath))
-> IO FilePath -> IO (Either IOException FilePath)
forall a b. (a -> b) -> a -> b
$ Handle -> IO FilePath
IO.hGetContents Handle
h)

hGetContents' :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r String
hGetContents' :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r FilePath
hGetContents' Handle
h = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetContents'"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO FilePath -> IO (Either IOException FilePath))
-> IO FilePath -> IO (Either IOException FilePath)
forall a b. (a -> b) -> a -> b
$ Handle -> IO FilePath
IO.hGetContents' Handle
h)

hPutChar :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Char
  -> Sem r ()
hPutChar :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Char -> Sem r ()
hPutChar Handle
h Char
c = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPutChar"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> Char -> IO ()
IO.hPutChar Handle
h Char
c)

hPutStr :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> String
  -> Sem r ()
hPutStr :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> FilePath -> Sem r ()
hPutStr Handle
h FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPutStr"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> FilePath -> IO ()
IO.hPutStr Handle
h FilePath
s)

hPutStrLn :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> String
  -> Sem r ()
hPutStrLn :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> FilePath -> Sem r ()
hPutStrLn Handle
h FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPutStrLn"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> FilePath -> IO ()
IO.hPutStrLn Handle
h FilePath
s)

hPrint :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> String
  -> Sem r ()
hPrint :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> FilePath -> Sem r ()
hPrint Handle
h FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPrint"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> FilePath -> IO ()
forall a. Show a => Handle -> a -> IO ()
IO.hPrint Handle
h FilePath
s)

interact :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => (String -> String)
  -> Sem r ()
interact :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
(FilePath -> FilePath) -> Sem r ()
interact FilePath -> FilePath
f = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called interact"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ (FilePath -> FilePath) -> IO ()
IO.interact FilePath -> FilePath
f)

putChar :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Char
  -> Sem r ()
putChar :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Char -> Sem r ()
putChar Char
c = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called putChar"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Char -> IO ()
IO.putChar Char
c)

putStr :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => String
  -> Sem r ()
putStr :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> Sem r ()
putStr FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called putStr"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ()
IO.putStr FilePath
s)

putStrLn :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => String
  -> Sem r ()
putStrLn :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> Sem r ()
putStrLn FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called putStrLn"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ()
IO.putStrLn FilePath
s)

print :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => String
  -> Sem r ()
print :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> Sem r ()
print FilePath
s = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called print"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ()
forall a. Show a => a -> IO ()
IO.print FilePath
s)

getChar :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r Char
getChar :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Sem r Char
getChar = (HasCallStack => Sem r Char) -> Sem r Char
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Char) -> Sem r Char)
-> (HasCallStack => Sem r Char) -> Sem r Char
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called getChar"
  Either IOException Char -> Sem r Char
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Char -> Sem r Char)
-> Sem r (Either IOException Char) -> Sem r Char
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Char) -> Sem r (Either IOException Char)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO Char
IO.getChar)

getLine :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r String
getLine :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Sem r FilePath
getLine = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called getLine"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO FilePath
IO.getLine)

getContents :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r String
getContents :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Sem r FilePath
getContents = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called getContents"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO FilePath
IO.getContents)

getContents' :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r String
getContents' :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Sem r FilePath
getContents' = (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r FilePath) -> Sem r FilePath)
-> (HasCallStack => Sem r FilePath) -> Sem r FilePath
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called getContents'"
  Either IOException FilePath -> Sem r FilePath
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException FilePath -> Sem r FilePath)
-> Sem r (Either IOException FilePath) -> Sem r FilePath
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException FilePath)
-> Sem r (Either IOException FilePath)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO FilePath
IO.getContents')

readIO :: ()
  => GHC.HasCallStack
  => Read a
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => String
  -> Sem r a
readIO :: forall a (r :: EffectRow).
(HasCallStack, Read a, Member (Error IOException) r,
 Member (Embed IO) r, Member Log r) =>
FilePath -> Sem r a
readIO FilePath
s = (HasCallStack => Sem r a) -> Sem r a
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r a) -> Sem r a)
-> (HasCallStack => Sem r a) -> Sem r a
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called readIO"
  Either IOException a -> Sem r a
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException a -> Sem r a)
-> Sem r (Either IOException a) -> Sem r a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException a) -> Sem r (Either IOException a)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO a -> IO (Either IOException a))
-> IO a -> IO (Either IOException a)
forall a b. (a -> b) -> a -> b
$ FilePath -> IO a
forall a. Read a => FilePath -> IO a
IO.readIO FilePath
s)

readLn :: ()
  => GHC.HasCallStack
  => Read a
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Sem r a
readLn :: forall a (r :: EffectRow).
(HasCallStack, Read a, Member (Error IOException) r,
 Member (Embed IO) r, Member Log r) =>
Sem r a
readLn = (HasCallStack => Sem r a) -> Sem r a
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r a) -> Sem r a)
-> (HasCallStack => Sem r a) -> Sem r a
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called readLn"
  Either IOException a -> Sem r a
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException a -> Sem r a)
-> Sem r (Either IOException a) -> Sem r a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException a) -> Sem r (Either IOException a)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException IO a
forall a. Read a => IO a
IO.readLn)

hPutBuf :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Ptr a
  -> Int
  -> Sem r ()
hPutBuf :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Ptr a -> Int -> Sem r ()
hPutBuf Handle
h Ptr a
ptr Int
n = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPutBuf"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> Ptr a -> Int -> IO ()
forall a. Handle -> Ptr a -> Int -> IO ()
IO.hPutBuf Handle
h Ptr a
ptr Int
n)

hGetBuf :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Ptr a
  -> Int
  -> Sem r Int
hGetBuf :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Ptr a -> Int -> Sem r Int
hGetBuf Handle
h Ptr a
ptr Int
n = (HasCallStack => Sem r Int) -> Sem r Int
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Int) -> Sem r Int)
-> (HasCallStack => Sem r Int) -> Sem r Int
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBuf"
  Either IOException Int -> Sem r Int
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Int -> Sem r Int)
-> Sem r (Either IOException Int) -> Sem r Int
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Int) -> Sem r (Either IOException Int)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Int -> IO (Either IOException Int))
-> IO Int -> IO (Either IOException Int)
forall a b. (a -> b) -> a -> b
$ Handle -> Ptr a -> Int -> IO Int
forall a. Handle -> Ptr a -> Int -> IO Int
IO.hGetBuf Handle
h Ptr a
ptr Int
n)

hGetBufSome :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Ptr a
  -> Int
  -> Sem r Int
hGetBufSome :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Ptr a -> Int -> Sem r Int
hGetBufSome Handle
h Ptr a
ptr Int
n = (HasCallStack => Sem r Int) -> Sem r Int
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Int) -> Sem r Int)
-> (HasCallStack => Sem r Int) -> Sem r Int
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBufSome"
  Either IOException Int -> Sem r Int
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Int -> Sem r Int)
-> Sem r (Either IOException Int) -> Sem r Int
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Int) -> Sem r (Either IOException Int)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Int -> IO (Either IOException Int))
-> IO Int -> IO (Either IOException Int)
forall a b. (a -> b) -> a -> b
$ Handle -> Ptr a -> Int -> IO Int
forall a. Handle -> Ptr a -> Int -> IO Int
IO.hGetBufSome Handle
h Ptr a
ptr Int
n)

hPutBufNonBlocking :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Ptr a
  -> Int
  -> Sem r Int
hPutBufNonBlocking :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Ptr a -> Int -> Sem r Int
hPutBufNonBlocking Handle
h Ptr a
ptr Int
n = (HasCallStack => Sem r Int) -> Sem r Int
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Int) -> Sem r Int)
-> (HasCallStack => Sem r Int) -> Sem r Int
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hPutBufNonBlocking"
  Either IOException Int -> Sem r Int
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Int -> Sem r Int)
-> Sem r (Either IOException Int) -> Sem r Int
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Int) -> Sem r (Either IOException Int)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Int -> IO (Either IOException Int))
-> IO Int -> IO (Either IOException Int)
forall a b. (a -> b) -> a -> b
$ Handle -> Ptr a -> Int -> IO Int
forall a. Handle -> Ptr a -> Int -> IO Int
IO.hPutBufNonBlocking Handle
h Ptr a
ptr Int
n)

hGetBufNonBlocking :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Ptr a
  -> Int
  -> Sem r Int
hGetBufNonBlocking :: forall (r :: EffectRow) a.
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Ptr a -> Int -> Sem r Int
hGetBufNonBlocking Handle
h Ptr a
ptr Int
n = (HasCallStack => Sem r Int) -> Sem r Int
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r Int) -> Sem r Int)
-> (HasCallStack => Sem r Int) -> Sem r Int
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetBufNonBlocking"
  Either IOException Int -> Sem r Int
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException Int -> Sem r Int)
-> Sem r (Either IOException Int) -> Sem r Int
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException Int) -> Sem r (Either IOException Int)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO Int -> IO (Either IOException Int))
-> IO Int -> IO (Either IOException Int)
forall a b. (a -> b) -> a -> b
$ Handle -> Ptr a -> Int -> IO Int
forall a. Handle -> Ptr a -> Int -> IO Int
IO.hGetBufNonBlocking Handle
h Ptr a
ptr Int
n)

openTempFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r (FilePath, Handle)
openTempFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r (FilePath, Handle)
openTempFile FilePath
fp FilePath
s = (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r (FilePath, Handle))
 -> Sem r (FilePath, Handle))
-> (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called openTempFile"
  Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle)
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO (FilePath, Handle)
 -> IO (Either IOException (FilePath, Handle)))
-> IO (FilePath, Handle)
-> IO (Either IOException (FilePath, Handle))
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO (FilePath, Handle)
IO.openTempFile FilePath
fp FilePath
s)

openBinaryTempFile :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r (FilePath, Handle)
openBinaryTempFile :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r (FilePath, Handle)
openBinaryTempFile FilePath
fp FilePath
s = (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r (FilePath, Handle))
 -> Sem r (FilePath, Handle))
-> (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called openBinaryTempFile"
  Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle)
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO (FilePath, Handle)
 -> IO (Either IOException (FilePath, Handle)))
-> IO (FilePath, Handle)
-> IO (Either IOException (FilePath, Handle))
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO (FilePath, Handle)
IO.openBinaryTempFile FilePath
fp FilePath
s)

openTempFileWithDefaultPermissions :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r (FilePath, Handle)
openTempFileWithDefaultPermissions :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r (FilePath, Handle)
openTempFileWithDefaultPermissions FilePath
fp FilePath
s = (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r (FilePath, Handle))
 -> Sem r (FilePath, Handle))
-> (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called openTempFileWithDefaultPermissions"
  Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle)
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO (FilePath, Handle)
 -> IO (Either IOException (FilePath, Handle)))
-> IO (FilePath, Handle)
-> IO (Either IOException (FilePath, Handle))
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO (FilePath, Handle)
IO.openTempFileWithDefaultPermissions FilePath
fp FilePath
s)

openBinaryTempFileWithDefaultPermissions :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => FilePath
  -> String
  -> Sem r (FilePath, Handle)
openBinaryTempFileWithDefaultPermissions :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> FilePath -> Sem r (FilePath, Handle)
openBinaryTempFileWithDefaultPermissions FilePath
fp FilePath
s = (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r (FilePath, Handle))
 -> Sem r (FilePath, Handle))
-> (HasCallStack => Sem r (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called openBinaryTempFileWithDefaultPermissions"
  Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle)
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException (FilePath, Handle) -> Sem r (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
-> Sem r (FilePath, Handle)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException (FilePath, Handle))
-> Sem r (Either IOException (FilePath, Handle))
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO (FilePath, Handle)
 -> IO (Either IOException (FilePath, Handle)))
-> IO (FilePath, Handle)
-> IO (Either IOException (FilePath, Handle))
forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> IO (FilePath, Handle)
IO.openBinaryTempFileWithDefaultPermissions FilePath
fp FilePath
s)

hSetEncoding :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> TextEncoding
  -> Sem r ()
hSetEncoding :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> TextEncoding -> Sem r ()
hSetEncoding Handle
h TextEncoding
enc = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSetEncoding"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> TextEncoding -> IO ()
IO.hSetEncoding Handle
h TextEncoding
enc)

hGetEncoding :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> Sem r (Maybe TextEncoding)
hGetEncoding :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> Sem r (Maybe TextEncoding)
hGetEncoding Handle
h = (HasCallStack => Sem r (Maybe TextEncoding))
-> Sem r (Maybe TextEncoding)
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r (Maybe TextEncoding))
 -> Sem r (Maybe TextEncoding))
-> (HasCallStack => Sem r (Maybe TextEncoding))
-> Sem r (Maybe TextEncoding)
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hGetEncoding"
  Either IOException (Maybe TextEncoding)
-> Sem r (Maybe TextEncoding)
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException (Maybe TextEncoding)
 -> Sem r (Maybe TextEncoding))
-> Sem r (Either IOException (Maybe TextEncoding))
-> Sem r (Maybe TextEncoding)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException (Maybe TextEncoding))
-> Sem r (Either IOException (Maybe TextEncoding))
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO (Maybe TextEncoding)
 -> IO (Either IOException (Maybe TextEncoding)))
-> IO (Maybe TextEncoding)
-> IO (Either IOException (Maybe TextEncoding))
forall a b. (a -> b) -> a -> b
$ Handle -> IO (Maybe TextEncoding)
IO.hGetEncoding Handle
h)

mkTextEncoding :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => String
  -> Sem r TextEncoding
mkTextEncoding :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
FilePath -> Sem r TextEncoding
mkTextEncoding FilePath
s = (HasCallStack => Sem r TextEncoding) -> Sem r TextEncoding
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r TextEncoding) -> Sem r TextEncoding)
-> (HasCallStack => Sem r TextEncoding) -> Sem r TextEncoding
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called mkTextEncoding"
  Either IOException TextEncoding -> Sem r TextEncoding
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException TextEncoding -> Sem r TextEncoding)
-> Sem r (Either IOException TextEncoding) -> Sem r TextEncoding
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException TextEncoding)
-> Sem r (Either IOException TextEncoding)
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO TextEncoding -> IO (Either IOException TextEncoding))
-> IO TextEncoding -> IO (Either IOException TextEncoding)
forall a b. (a -> b) -> a -> b
$ FilePath -> IO TextEncoding
IO.mkTextEncoding FilePath
s)

hSetNewlineMode :: ()
  => GHC.HasCallStack
  => Member (Error IOException) r
  => Member (Embed IO) r
  => Member Log r
  => Handle
  -> NewlineMode
  -> Sem r ()
hSetNewlineMode :: forall (r :: EffectRow).
(HasCallStack, Member (Error IOException) r, Member (Embed IO) r,
 Member Log r) =>
Handle -> NewlineMode -> Sem r ()
hSetNewlineMode Handle
h NewlineMode
nm = (HasCallStack => Sem r ()) -> Sem r ()
forall a. HasCallStack => (HasCallStack => a) -> a
GHC.withFrozenCallStack ((HasCallStack => Sem r ()) -> Sem r ())
-> (HasCallStack => Sem r ()) -> Sem r ()
forall a b. (a -> b) -> a -> b
$ do
  Text -> Sem r ()
forall (r :: EffectRow).
(HasCallStack, Member Log r) =>
Text -> Sem r ()
debug Text
"Called hSetNewlineMode"
  Either IOException () -> Sem r ()
forall e (r :: EffectRow) a.
Member (Error e) r =>
Either e a -> Sem r a
fromEither (Either IOException () -> Sem r ())
-> Sem r (Either IOException ()) -> Sem r ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Either IOException ()) -> Sem r (Either IOException ())
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
embed (forall e a. Exception e => IO a -> IO (Either e a)
CE.try @IOException (IO () -> IO (Either IOException ()))
-> IO () -> IO (Either IOException ())
forall a b. (a -> b) -> a -> b
$ Handle -> NewlineMode -> IO ()
IO.hSetNewlineMode Handle
h NewlineMode
nm)