ormolu-0.7.4.0: A formatter for Haskell source code

Safe Haskell | None
Language | GHC2021

Ormolu.Utils.IO

Description

Write `Text` to files using UTF8 and ignoring native line ending conventions.

Synopsis

- writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()
- readFileUtf8 :: MonadIO m => FilePath -> m Text
- getContentsUtf8 :: MonadIO m => m Text
- findClosestFileSatisfying :: MonadIO m => (FilePath -> Bool) -> FilePath -> m (Maybe FilePath)
- withIORefCache :: Ord k => IORef (Map k v) -> k -> IO v -> IO v

# Documentation

writeFileUtf8 :: MonadIO m => FilePath -> Text -> m () #

Write a `Text` to a file using UTF8 and ignoring native line ending conventions.

readFileUtf8 :: MonadIO m => FilePath -> m Text #

Read an entire file strictly into a `Text` using UTF8 and ignoring native line ending conventions.

getContentsUtf8 :: MonadIO m => m Text #

Read stdin as UTF8-encoded `Text` value.

findClosestFileSatisfying #

Arguments

:: MonadIO m |
=> (FilePath -> Bool) | The predicate that determines what we are looking for
-> FilePath | Path to the starting point for the search
-> m (Maybe FilePath) | Absolute path to the found file if available

Find the path to the closest file higher in the file hierarchy that satisfies a given predicate.

withIORefCache :: Ord k => IORef (Map k v) -> k -> IO v -> IO v #

Execute an `IO` action but only if the given key is not found in the `IORef` cache.