Safe Haskell | None |
---|---|
Language | Haskell2010 |
Contains logic for reading configuration files.
- readConfigFile :: forall e m a. (MonadThrow m, Functor m, MonadIO m, Default a, Exception e) => FilePath -> (ByteString -> Either e a) -> (a -> ByteString) -> m a
- readConfigJSON :: forall m a. (MonadThrow m, Functor m, MonadIO m, Default a, ToJSON a, FromJSON a) => FilePath -> m a
- readConfigShow :: forall m a. (MonadThrow m, Functor m, MonadIO m, Default a, Show a, Read a) => FilePath -> m a
- data NoParseError = NoParseError Text
Documentation
:: (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.