module Data.Text.Lazy.IO.Utf8
( readFile
, writeFile
) where
import Prelude hiding (readFile, writeFile)
import Control.Exception.Safe (MonadMask)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy.IO as T
import qualified System.IO as IO
import qualified System.IO.Utf8 as Utf8
readFile :: MonadIO m => IO.FilePath -> m Text
readFile path = Utf8.openFile path IO.ReadMode >>= liftIO . T.hGetContents
writeFile :: (MonadIO m, MonadMask m) => IO.FilePath -> Text -> m ()
writeFile path = Utf8.withFile path IO.WriteMode . (liftIO .) . flip T.hPutStr