Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type ConfigKey = Text
- type ConfigMap = Object
- type EnvConfigMap = KeyMap String
- data ExternalConfig = ExternalConfig {}
- data Configurable a where
- ConfigFromFile :: FromJSON a => ConfigKey -> Configurable a
- ConfigFromEnv :: FromJSON a => ConfigKey -> Configurable a
- Literal :: a -> Configurable a
- render :: forall a. Configurable a -> ExternalConfig -> Either String (Configurable a)
- getConfigKey :: Configurable a -> Maybe ConfigKey
- data ConfigKeysBySource = ConfigKeysBySource {
- fileConfigKeys :: !(HashSet Text)
- envConfigKeys :: !(HashSet Text)
- configKeyBySource :: Configurable a -> ConfigKeysBySource
- missing :: ExternalConfig -> ConfigKeysBySource -> [ConfigKey]
- readEnv :: MonadIO m => ConfigKey -> m (KeyMap String)
- readEnvs :: MonadIO m => [ConfigKey] -> m (KeyMap String)
- readYamlFileConfig :: (MonadIO m, FromJSON a) => FilePath -> m a
Documentation
type EnvConfigMap = KeyMap String Source #
data ExternalConfig Source #
Instances
Show ExternalConfig Source # | |
Defined in Funflow.Config showsPrec :: Int -> ExternalConfig -> ShowS # show :: ExternalConfig -> String # showList :: [ExternalConfig] -> ShowS # |
data Configurable a where Source #
A value which is intended to be populated using an external source (e.g. a config file)
ConfigFromFile :: FromJSON a => ConfigKey -> Configurable a | Define a configurable which will be loaded from a config file using the given key |
ConfigFromEnv :: FromJSON a => ConfigKey -> Configurable a | Define a configurable which will be loaded from the specified environment variable |
Literal :: a -> Configurable a | A literal value which does not need to be loaded from an external config source |
render :: forall a. Configurable a -> ExternalConfig -> Either String (Configurable a) Source #
Render a Configurable into a Literal value using a set of external configurations, returning an error message if rendering failed.
getConfigKey :: Configurable a -> Maybe ConfigKey Source #
Gets the config key for a configurable value, if it exists.
data ConfigKeysBySource Source #
Stores ConfigKey values by their declared sources.
ConfigKeysBySource | |
|
Instances
Show ConfigKeysBySource Source # | |
Defined in Funflow.Config showsPrec :: Int -> ConfigKeysBySource -> ShowS # show :: ConfigKeysBySource -> String # showList :: [ConfigKeysBySource] -> ShowS # | |
Semigroup ConfigKeysBySource Source # | |
Defined in Funflow.Config (<>) :: ConfigKeysBySource -> ConfigKeysBySource -> ConfigKeysBySource # sconcat :: NonEmpty ConfigKeysBySource -> ConfigKeysBySource # stimes :: Integral b => b -> ConfigKeysBySource -> ConfigKeysBySource # | |
Monoid ConfigKeysBySource Source # | |
Defined in Funflow.Config |
configKeyBySource :: Configurable a -> ConfigKeysBySource Source #
Get the key of a Configurable
as a ConfigKeysBySource
.
missing :: ExternalConfig -> ConfigKeysBySource -> [ConfigKey] Source #
Get a list of any ConfigKeys which don't exist in their corresponding field in the providedExternalConfig
readEnv :: MonadIO m => ConfigKey -> m (KeyMap String) Source #
Construct an HashMap containing specified environment variable values.
readEnvs :: MonadIO m => [ConfigKey] -> m (KeyMap String) Source #
Convenience function for calling readEnv on a list of ConfigKeys
readYamlFileConfig :: (MonadIO m, FromJSON a) => FilePath -> m a Source #
Construct a HashMap containing the content of a yaml file. Is just an Alias for decodeFileThrow
.