{- generated by Isabelle -}

   Title :       Isabelle / File.hs 
     Author :      Makarius 
     LICENSE :     BSD 3 - clause ( Isabelle ) 

 File - system operations . 

 See " $ ISABELLE_HOME / src / Pure / General / file . ML " . 

    Author:     Makarius
    LICENSE:    BSD 3-clause (Isabelle)

File-system operations.

See "$ISABELLE_HOME/src/Pure/General/file.ML".
-}

module Isabelle.File (read, write, append) where

import Prelude hiding (read)
import qualified System.IO as IO
import qualified Data.ByteString as ByteString
import qualified Isabelle.Bytes as Bytes
import Isabelle.Bytes (Bytes)

read :: IO.FilePath -> IO Bytes
read path = Bytes.make <$> IO.withFile path IO.ReadMode ByteString.hGetContents

write :: IO.FilePath -> Bytes -> IO ()
write path bs = IO.withFile path IO.WriteMode (\h -> ByteString.hPut h (Bytes.unmake bs))

append :: IO.FilePath -> Bytes -> IO ()
append path bs = IO.withFile path IO.AppendMode (\h -> ByteString.hPut h (Bytes.unmake bs))

 generated by Isabelle 

   Title :       Isabelle / File.hs 
     Author :      Makarius 
     LICENSE :     BSD 3 - clause ( Isabelle ) 

 File - system operations . 

 See " $ ISABELLE_HOME / src / Pure / General / file . ML " . 

    Author:     Makarius
    LICENSE:    BSD 3-clause (Isabelle)

File-system operations.

See "$ISABELLE_HOME/src/Pure/General/file.ML".
-}

module Isabelle.File (read, write, append) where

import Prelude hiding (read)
import qualified System.IO as IO
import qualified Data.ByteString as ByteString
import qualified Isabelle.Bytes as Bytes
import Isabelle.Bytes (Bytes)

read :: IO.FilePath -> IO Bytes
read path = Bytes.make <$> IO.withFile path IO.ReadMode ByteString.hGetContents

write :: IO.FilePath -> Bytes -> IO ()
write path bs = IO.withFile path IO.WriteMode (\h -> ByteString.hPut h (Bytes.unmake bs))

append :: IO.FilePath -> Bytes -> IO ()
append path bs = IO.withFile path IO.AppendMode (\h -> ByteString.hPut h (Bytes.unmake bs))
