1{- | Parser for the [scfg](https://codeberg.org/emersion/scfg)2configuration file format.3-}4module Data.Scfg (5 parse,6 parseFile,7 format,8 formatFile,9 Directive (..),10 Config,11 ParseError (..),12) where1314import qualified Data.Scfg.Formatter as F15import qualified Data.Scfg.Parser as P16import Data.Scfg.Types17import Data.Text (Text)18import qualified Data.Text.IO as TIO1920{- | Parse scfg from 'Text'. Returns a 'Data.Scfg.Types.ParseError' if21the input is not valid scfg.22-}23parse :: Text -> Either ParseError Config24parse = P.parseConfig2526{- | Parse scfg from a file. Returns a 'Data.Scfg.Types.ParseError' if27the input is not valid scfg or if the file cannot be read.28-}29parseFile :: FilePath -> IO (Either ParseError Config)30parseFile path = parse <$> TIO.readFile path3132{- | Format a 'Config' as a canonical 'Text' representation. All words33are double-quoted and blocks indented with tabs.34-}35format :: Config -> Text36format = F.format3738{- | Format a 'Config' and write it to a file. Returns an 'IOError' if39the file cannot be written.40-}41formatFile :: FilePath -> Config -> IO ()42formatFile path = TIO.writeFile path . F.format