repl-toolkit-0.4.0.0: Toolkit for quickly whipping up config files and command-line interfaces.

Safe HaskellNone
LanguageHaskell2010

System.REPL.Config

Description

Contains logic for reading configuration files.

Synopsis

Documentation

readConfigFile Source

Arguments

:: (MonadThrow m, Functor m, MonadIO m, Default a, Exception e) 
=> FilePath

Path of the configuration file.

-> (ByteString -> Either e a)

Parser for the file's contents.

-> (a -> ByteString)

Encoder for the default value. If the given configuration file does not exist, a default value will be serialized using this function.

-> m a 

Tries to read a configuration from file. If the file is missing, a default instance is written to file and returned. The following exceptions may be thrown:

  • IOException, if the IO operations associated with reading or creating the configuration file fail, and
  • An exception of type e if the configuration file is present, but its contents can't be parsed.

readConfigJSON :: forall m a. (MonadThrow m, Functor m, MonadIO m, Default a, ToJSON a, FromJSON a) => FilePath -> m a Source

Variant of readConfigFile that uses JSON for (de)serialization.

If the file's content's can't be parsed, a NoParseError will be thrown.

readConfigShow :: forall m a. (MonadThrow m, Functor m, MonadIO m, Default a, Show a, Read a) => FilePath -> m a Source

Variant of readConfigFile that uses Show and Read for (de)serialization.

If the file's content's can't be parsed, a NoParseError will be thrown.

data NoParseError Source

Indicates that some string was not able to be parsed.

Constructors

NoParseError Text