conftrack-0.0.1: Tracable multi-source config management
Safe HaskellSafe-Inferred
LanguageGHC2021

Conftrack.Source

Synopsis

Documentation

class ConfigSource s where Source #

An abstraction over "config sources". This might mean file formats, environment variables, or any other kind of format that can be seen as a key-value store.

Associated Types

type SourceState s Source #

Some sources require state, e.g. to keep track of which values were already read.

Methods

fetchValue :: Key -> s -> StateT (SourceState s) IO (Either ConfigError (Value, Text)) Source #

read a single value from the source.

leftovers :: s -> StateT (SourceState s) IO (Maybe [Key]) Source #

given s, determine if any keys are "left over" and were not used. This is used to produce warnings for unknown configuration options; since not all sources can support this, this function's return type includes Maybe and sources are free to return Nothing if they cannot determine if any unknown keys are present.

data SomeSource Source #

An opaque type for any kind of config sources. Values of this type can be acquired from they Conftrack.Source.* modules, or by implementing the ConfigSource type class.

Constructors

forall source.ConfigSource source => SomeSource (source, SourceState source)