relude-0.7.0.0: Safe, performant, user-friendly and lightweight Haskell Standard Library
Copyright(c) 2018-2020 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Relude.File

Description

Lifted to MonadIO families of file processing functions for the Text, LText, ByteString and LByteString types.

These functions are lifted which means that you can also use them inside various Monad Transformers without adding liftIO call explicitly.

NOTE: These functions are for working with textual data. Functions that work with Text or LText types are system and locale-sensitive (encoding, line-endings). If you want binary data, use ByteString functions (they are also faster since they don't check encoding). However, you can then decode that data with the help of functions from the Relude.String.Conversion module, e. g. decodeUtf8.

Since: 0.3.0

Synopsis

Text

readFileText :: MonadIO m => FilePath -> m Text Source #

Lifted version of readFile.

Since: 0.3.0

writeFileText :: MonadIO m => FilePath -> Text -> m () Source #

Lifted version of writeFile.

Since: 0.3.0

appendFileText :: MonadIO m => FilePath -> Text -> m () Source #

Lifted version of appendFile.

Since: 0.3.0

Lazy Text

readFileLText :: MonadIO m => FilePath -> m LText Source #

Lifted version of readFile.

Since: 0.3.0

writeFileLText :: MonadIO m => FilePath -> LText -> m () Source #

Lifted version of writeFile.

Since: 0.3.0

appendFileLText :: MonadIO m => FilePath -> LText -> m () Source #

Lifted version of appendFile.

Since: 0.3.0

ByteString

readFileBS :: MonadIO m => FilePath -> m ByteString Source #

Lifted version of readFile.

Since: 0.3.0

writeFileBS :: MonadIO m => FilePath -> ByteString -> m () Source #

Lifted version of writeFile.

Since: 0.3.0

appendFileBS :: MonadIO m => FilePath -> ByteString -> m () Source #

Lifted version of appendFile.

Since: 0.3.0

Lazy ByteString

readFileLBS :: MonadIO m => FilePath -> m LByteString Source #

Lifted version of readFile.

Since: 0.3.0

writeFileLBS :: MonadIO m => FilePath -> LByteString -> m () Source #

Lifted version of writeFile.

Since: 0.3.0

appendFileLBS :: MonadIO m => FilePath -> LByteString -> m () Source #

Lifted version of appendFile.

Since: 0.3.0