Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Conftrack.Source
Synopsis
- class ConfigSource s where
- type SourceState s
- fetchValue :: Key -> s -> StateT (SourceState s) IO (Either ConfigError (Value, Text))
- leftovers :: s -> StateT (SourceState s) IO (Maybe [Key])
- data SomeSource = forall source.ConfigSource source => SomeSource (source, SourceState source)
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.
Instances
ConfigSource JsonSource Source # | |
Defined in Conftrack.Source.Aeson Associated Types type SourceState JsonSource Source # Methods fetchValue :: Key -> JsonSource -> StateT (SourceState JsonSource) IO (Either ConfigError (Value, Text)) Source # leftovers :: JsonSource -> StateT (SourceState JsonSource) IO (Maybe [Key]) Source # | |
ConfigSource EnvSource Source # | |
Defined in Conftrack.Source.Env Associated Types type SourceState EnvSource Source # | |
ConfigSource Trivial Source # | |
Defined in Conftrack.Source.Trivial Associated Types type SourceState Trivial Source # | |
ConfigSource YamlSource Source # | |
Defined in Conftrack.Source.Yaml Associated Types type SourceState YamlSource Source # Methods fetchValue :: Key -> YamlSource -> StateT (SourceState YamlSource) IO (Either ConfigError (Value, Text)) Source # leftovers :: YamlSource -> StateT (SourceState YamlSource) IO (Maybe [Key]) Source # |
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) |