-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Declarative configuration spec for Haskell projects -- -- etc gathers configuration values from multiple sources (cli -- options, OS environment variables, files) using a declarative spec -- file that defines where these values are to be found and located in a -- configuration map. @package etc @version 0.3.0.0 module System.Etc.Internal.Spec.Types data ConfigurationError InvalidConfiguration :: !(Maybe Text) -> !Text -> ConfigurationError InvalidConfigKeyPath :: ![Text] -> ConfigurationError ConfigurationFileNotFound :: !Text -> ConfigurationError data CliOptValueType StringOpt :: CliOptValueType NumberOpt :: CliOptValueType SwitchOpt :: CliOptValueType data CliArgValueType StringArg :: CliArgValueType NumberArg :: CliArgValueType data CliEntryMetadata Opt :: !(Maybe Text) -> !(Maybe Text) -> !(Maybe Text) -> !(Maybe Text) -> !Bool -> !CliOptValueType -> CliEntryMetadata [optLong] :: CliEntryMetadata -> !(Maybe Text) [optShort] :: CliEntryMetadata -> !(Maybe Text) [optMetavar] :: CliEntryMetadata -> !(Maybe Text) [optHelp] :: CliEntryMetadata -> !(Maybe Text) [optRequired] :: CliEntryMetadata -> !Bool [optValueType] :: CliEntryMetadata -> !CliOptValueType Arg :: !(Maybe Text) -> !Bool -> !CliArgValueType -> CliEntryMetadata [argMetavar] :: CliEntryMetadata -> !(Maybe Text) [optRequired] :: CliEntryMetadata -> !Bool [argValueType] :: CliEntryMetadata -> !CliArgValueType data CliEntrySpec cmd CmdEntry :: !(Vector cmd) -> !CliEntryMetadata -> CliEntrySpec cmd [cliEntryCmdValue] :: CliEntrySpec cmd -> !(Vector cmd) [cliEntryMetadata] :: CliEntrySpec cmd -> !CliEntryMetadata PlainEntry :: !CliEntryMetadata -> CliEntrySpec cmd [cliEntryMetadata] :: CliEntrySpec cmd -> !CliEntryMetadata data CliCmdSpec CliCmdSpec :: !Text -> !Text -> CliCmdSpec [cliCmdDesc] :: CliCmdSpec -> !Text [cliCmdHeader] :: CliCmdSpec -> !Text data ConfigSources cmd ConfigSources :: !(Maybe Text) -> !(Maybe (CliEntrySpec cmd)) -> ConfigSources cmd [envVar] :: ConfigSources cmd -> !(Maybe Text) [cliEntry] :: ConfigSources cmd -> !(Maybe (CliEntrySpec cmd)) data ConfigValue cmd ConfigValue :: !(Maybe Value) -> !Bool -> !(ConfigSources cmd) -> ConfigValue cmd [defaultValue] :: ConfigValue cmd -> !(Maybe Value) [isSensitive] :: ConfigValue cmd -> !Bool [configSources] :: ConfigValue cmd -> !(ConfigSources cmd) SubConfig :: !(HashMap Text (ConfigValue cmd)) -> ConfigValue cmd [subConfig] :: ConfigValue cmd -> !(HashMap Text (ConfigValue cmd)) data CliProgramSpec CliProgramSpec :: !Text -> !Text -> !(Maybe (HashMap Text CliCmdSpec)) -> CliProgramSpec [cliProgramDesc] :: CliProgramSpec -> !Text [cliProgramHeader] :: CliProgramSpec -> !Text [cliCommands] :: CliProgramSpec -> !(Maybe (HashMap Text CliCmdSpec)) data ConfigSpec cmd ConfigSpec :: ![Text] -> !(Maybe CliProgramSpec) -> !(HashMap Text (ConfigValue cmd)) -> ConfigSpec cmd [specConfigFilepaths] :: ConfigSpec cmd -> ![Text] [specCliProgramSpec] :: ConfigSpec cmd -> !(Maybe CliProgramSpec) [specConfigValues] :: ConfigSpec cmd -> !(HashMap Text (ConfigValue cmd)) cliArgTypeParser :: Object -> Parser CliArgValueType cliArgParser :: Object -> Parser CliEntryMetadata cliOptTypeParser :: Object -> Parser CliOptValueType cliOptParser :: Object -> Parser CliEntryMetadata cliArgKeys :: [Text] cliOptKeys :: [Text] instance GHC.Classes.Eq cmd => GHC.Classes.Eq (System.Etc.Internal.Spec.Types.ConfigSpec cmd) instance GHC.Show.Show cmd => GHC.Show.Show (System.Etc.Internal.Spec.Types.ConfigSpec cmd) instance GHC.Classes.Eq System.Etc.Internal.Spec.Types.CliProgramSpec instance GHC.Show.Show System.Etc.Internal.Spec.Types.CliProgramSpec instance GHC.Classes.Eq cmd => GHC.Classes.Eq (System.Etc.Internal.Spec.Types.ConfigValue cmd) instance GHC.Show.Show cmd => GHC.Show.Show (System.Etc.Internal.Spec.Types.ConfigValue cmd) instance GHC.Classes.Eq cmd => GHC.Classes.Eq (System.Etc.Internal.Spec.Types.ConfigSources cmd) instance GHC.Show.Show cmd => GHC.Show.Show (System.Etc.Internal.Spec.Types.ConfigSources cmd) instance GHC.Classes.Eq System.Etc.Internal.Spec.Types.CliCmdSpec instance GHC.Show.Show System.Etc.Internal.Spec.Types.CliCmdSpec instance GHC.Classes.Eq cmd => GHC.Classes.Eq (System.Etc.Internal.Spec.Types.CliEntrySpec cmd) instance GHC.Show.Show cmd => GHC.Show.Show (System.Etc.Internal.Spec.Types.CliEntrySpec cmd) instance GHC.Classes.Eq System.Etc.Internal.Spec.Types.CliEntryMetadata instance GHC.Show.Show System.Etc.Internal.Spec.Types.CliEntryMetadata instance GHC.Classes.Eq System.Etc.Internal.Spec.Types.CliArgValueType instance GHC.Show.Show System.Etc.Internal.Spec.Types.CliArgValueType instance GHC.Classes.Eq System.Etc.Internal.Spec.Types.CliOptValueType instance GHC.Show.Show System.Etc.Internal.Spec.Types.CliOptValueType instance GHC.Show.Show System.Etc.Internal.Spec.Types.ConfigurationError instance Data.Aeson.Types.FromJSON.FromJSON cmd => Data.Aeson.Types.FromJSON.FromJSON (System.Etc.Internal.Spec.Types.ConfigSpec cmd) instance Data.Aeson.Types.FromJSON.FromJSON System.Etc.Internal.Spec.Types.CliProgramSpec instance Data.Aeson.Types.FromJSON.FromJSON cmd => Data.Aeson.Types.FromJSON.FromJSON (System.Etc.Internal.Spec.Types.ConfigValue cmd) instance Data.Aeson.Types.FromJSON.FromJSON System.Etc.Internal.Spec.Types.CliCmdSpec instance Data.Aeson.Types.FromJSON.FromJSON cmd => Data.Aeson.Types.FromJSON.FromJSON (System.Etc.Internal.Spec.Types.CliEntrySpec cmd) instance GHC.Exception.Exception System.Etc.Internal.Spec.Types.ConfigurationError module System.Etc.Internal.Spec.JSON parseConfigSpec :: (MonadThrow m, FromJSON cmd) => Text -> m (ConfigSpec cmd) readConfigSpec :: FromJSON cmd => Text -> IO (ConfigSpec cmd) module System.Etc.Internal.Types data Value a Plain :: !a -> Value a [fromValue] :: Value a -> !a Sensitive :: !a -> Value a [fromValue] :: Value a -> !a boolToValue :: Bool -> (a -> Value a) data ConfigSource File :: !Int -> !Text -> !(Value Value) -> ConfigSource [configIndex] :: ConfigSource -> !Int [filepath] :: ConfigSource -> !Text [value] :: ConfigSource -> !(Value Value) Env :: !Text -> !(Value Value) -> ConfigSource [envVar] :: ConfigSource -> !Text [value] :: ConfigSource -> !(Value Value) Cli :: !(Value Value) -> ConfigSource [value] :: ConfigSource -> !(Value Value) Default :: !(Value Value) -> ConfigSource [value] :: ConfigSource -> !(Value Value) None :: ConfigSource data ConfigValue ConfigValue :: !(Set ConfigSource) -> ConfigValue [configSource] :: ConfigValue -> !(Set ConfigSource) SubConfig :: !(HashMap Text ConfigValue) -> ConfigValue [configMap] :: ConfigValue -> !(HashMap Text ConfigValue) deepMerge :: ConfigValue -> ConfigValue -> ConfigValue newtype Config Config :: ConfigValue -> Config [fromConfig] :: Config -> ConfigValue isEmptySubConfig :: ConfigValue -> Bool emptySubConfig :: ConfigValue writeInSubConfig :: Text -> ConfigValue -> ConfigValue -> ConfigValue filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a class IConfig config -- | Fetches a configuration value from a given key, if key is not found, -- you may pick the failure mode via the MonadThrow interface. -- -- example: -- --
--   >>> getConfigValue ["db", "user"] config :: Maybe Text
--   Just "root"
--   
--   >>> getConfigValue ["db", "password"] config :: Maybe Text
--   Nothing
--   
getConfigValue :: (IConfig config, MonadThrow m, FromJSON result) => [Text] -> config -> m result -- | Fetches a configuration value from a given key, normally this key will -- point to a sub-config JSON object, which is then passed to the given -- JSON parser function. If key is not found, you may pick the failure -- mode via the MonadThrow interface. -- -- example: -- --
--   >>> import qualified Data.Aeson as JSON
--   
--   >>> import qualified Data.Aeson.Types as JSON (Parser)
--   
-- --
--   >>> connectInfoParser :: JSON.Value -> JSON.Parser DbConnectInfo
--   
-- --
--   >>> getConfigValueWith connectInfoParser ["db"] config
--   Just (DbConnectInfo {...})
--   
getConfigValueWith :: (IConfig config, (MonadThrow m)) => (Value -> Parser result) -> [Text] -> config -> m result getAllConfigSources :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m (Set ConfigSource) getSelectedConfigSource :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m ConfigSource instance GHC.Base.Monoid System.Etc.Internal.Types.Config instance Data.Semigroup.Semigroup System.Etc.Internal.Types.Config instance GHC.Show.Show System.Etc.Internal.Types.Config instance GHC.Classes.Eq System.Etc.Internal.Types.Config instance GHC.Show.Show System.Etc.Internal.Types.ConfigValue instance GHC.Classes.Eq System.Etc.Internal.Types.ConfigValue instance GHC.Classes.Eq System.Etc.Internal.Types.ConfigSource instance GHC.Show.Show System.Etc.Internal.Types.ConfigSource instance GHC.Classes.Ord a => GHC.Classes.Ord (System.Etc.Internal.Types.Value a) instance GHC.Classes.Eq a => GHC.Classes.Eq (System.Etc.Internal.Types.Value a) instance GHC.Generics.Generic (System.Etc.Internal.Types.Value a) instance Data.Semigroup.Semigroup System.Etc.Internal.Types.ConfigValue instance GHC.Base.Monoid System.Etc.Internal.Types.ConfigValue instance GHC.Classes.Ord System.Etc.Internal.Types.ConfigSource instance GHC.Show.Show a => GHC.Show.Show (System.Etc.Internal.Types.Value a) instance GHC.Base.Functor System.Etc.Internal.Types.Value instance GHC.Base.Applicative System.Etc.Internal.Types.Value instance Data.String.IsString a => Data.String.IsString (System.Etc.Internal.Types.Value a) module System.Etc.Internal.Resolver.File -- | Gathers configuration values from a list of files specified on the -- etc/filepaths entry of a Config Spec. This will return a -- Configuration Map with values from all filepaths merged in, and a list -- of errors in case there was an error reading one of the filepaths. resolveFiles :: ConfigSpec cmd -> IO (Config, Vector SomeException) instance GHC.Classes.Eq System.Etc.Internal.Resolver.File.ConfigFile instance GHC.Show.Show System.Etc.Internal.Resolver.File.ConfigFile module System.Etc.Internal.Resolver.Env -- | Gathers all OS Environment Variable values (env entries) from -- the etc/spec entries inside a ConfigSpec. resolveEnv :: ConfigSpec cmd -> IO Config -- | Gathers all OS Environment Variable values (env entries) from -- the etc/spec entries inside a ConfigSpec. This -- version of the function gathers the input from a list of tuples rather -- than the OS. resolveEnvPure :: ConfigSpec cmd -> [(Text, Text)] -> Config module System.Etc.Internal.Resolver.Default -- | Gathers all default values from the etc/spec entries inside a -- ConfigSpec resolveDefault :: ConfigSpec cmd -> Config module System.Etc.Internal.Config configValueToJsonObject :: ConfigValue -> Value _getConfigValueWith :: MonadThrow m => (Value -> Parser result) -> [Text] -> Config -> m result _getSelectedConfigSource :: (MonadThrow m) => [Text] -> Config -> m ConfigSource _getAllConfigSources :: (MonadThrow m) => [Text] -> Config -> m (Set ConfigSource) _getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> Config -> m result instance System.Etc.Internal.Types.IConfig System.Etc.Internal.Types.Config module System.Etc.Spec -- | Parses a text input into a ConfigSpec, input can be JSON or -- YAML (if cabal flag is set). parseConfigSpec :: (MonadThrow m) => Text -> m (ConfigSpec ()) -- | Reads contents of a file and parses into a ConfigSpec, file -- contents can be either JSON or YAML (if cabal flag is set). readConfigSpec :: Text -> IO (ConfigSpec ()) module System.Etc data Config class IConfig config -- | Fetches a configuration value from a given key, if key is not found, -- you may pick the failure mode via the MonadThrow interface. -- -- example: -- --
--   >>> getConfigValue ["db", "user"] config :: Maybe Text
--   Just "root"
--   
--   >>> getConfigValue ["db", "password"] config :: Maybe Text
--   Nothing
--   
getConfigValue :: (IConfig config, MonadThrow m, FromJSON result) => [Text] -> config -> m result -- | Fetches a configuration value from a given key, normally this key will -- point to a sub-config JSON object, which is then passed to the given -- JSON parser function. If key is not found, you may pick the failure -- mode via the MonadThrow interface. -- -- example: -- --
--   >>> import qualified Data.Aeson as JSON
--   
--   >>> import qualified Data.Aeson.Types as JSON (Parser)
--   
-- --
--   >>> connectInfoParser :: JSON.Value -> JSON.Parser DbConnectInfo
--   
-- --
--   >>> getConfigValueWith connectInfoParser ["db"] config
--   Just (DbConnectInfo {...})
--   
getConfigValueWith :: (IConfig config, (MonadThrow m)) => (Value -> Parser result) -> [Text] -> config -> m result getAllConfigSources :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m (Set ConfigSource) getSelectedConfigSource :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m ConfigSource data Value a Plain :: !a -> Value a [fromValue] :: Value a -> !a Sensitive :: !a -> Value a [fromValue] :: Value a -> !a -- | Fetches a configuration value from a given key, if key is not found, -- you may pick the failure mode via the MonadThrow interface. -- -- example: -- --
--   >>> getConfigValue ["db", "user"] config :: Maybe Text
--   Just "root"
--   
--   >>> getConfigValue ["db", "password"] config :: Maybe Text
--   Nothing
--   
getConfigValue :: (IConfig config, MonadThrow m, FromJSON result) => [Text] -> config -> m result -- | Fetches a configuration value from a given key, normally this key will -- point to a sub-config JSON object, which is then passed to the given -- JSON parser function. If key is not found, you may pick the failure -- mode via the MonadThrow interface. -- -- example: -- --
--   >>> import qualified Data.Aeson as JSON
--   
--   >>> import qualified Data.Aeson.Types as JSON (Parser)
--   
-- --
--   >>> connectInfoParser :: JSON.Value -> JSON.Parser DbConnectInfo
--   
-- --
--   >>> getConfigValueWith connectInfoParser ["db"] config
--   Just (DbConnectInfo {...})
--   
getConfigValueWith :: (IConfig config, (MonadThrow m)) => (Value -> Parser result) -> [Text] -> config -> m result getSelectedConfigSource :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m ConfigSource getAllConfigSources :: (IConfig config, (MonadThrow m)) => [Text] -> config -> m (Set ConfigSource) data ConfigSource File :: !Int -> !Text -> !(Value Value) -> ConfigSource [configIndex] :: ConfigSource -> !Int [filepath] :: ConfigSource -> !Text [value] :: ConfigSource -> !(Value Value) Env :: !Text -> !(Value Value) -> ConfigSource [envVar] :: ConfigSource -> !Text [value] :: ConfigSource -> !(Value Value) Cli :: !(Value Value) -> ConfigSource [value] :: ConfigSource -> !(Value Value) Default :: !(Value Value) -> ConfigSource [value] :: ConfigSource -> !(Value Value) None :: ConfigSource data ConfigValue data ConfigSpec cmd data ConfigurationError InvalidConfiguration :: !(Maybe Text) -> !Text -> ConfigurationError InvalidConfigKeyPath :: ![Text] -> ConfigurationError ConfigurationFileNotFound :: !Text -> ConfigurationError -- | Parses a text input into a ConfigSpec, input can be JSON or -- YAML (if cabal flag is set). parseConfigSpec :: (MonadThrow m) => Text -> m (ConfigSpec ()) -- | Reads contents of a file and parses into a ConfigSpec, file -- contents can be either JSON or YAML (if cabal flag is set). readConfigSpec :: Text -> IO (ConfigSpec ()) -- | Gathers all default values from the etc/spec entries inside a -- ConfigSpec resolveDefault :: ConfigSpec cmd -> Config -- | Gathers configuration values from a list of files specified on the -- etc/filepaths entry of a Config Spec. This will return a -- Configuration Map with values from all filepaths merged in, and a list -- of errors in case there was an error reading one of the filepaths. resolveFiles :: ConfigSpec cmd -> IO (Config, Vector SomeException) -- | Gathers all OS Environment Variable values (env entries) from -- the etc/spec entries inside a ConfigSpec. This -- version of the function gathers the input from a list of tuples rather -- than the OS. resolveEnvPure :: ConfigSpec cmd -> [(Text, Text)] -> Config -- | Gathers all OS Environment Variable values (env entries) from -- the etc/spec entries inside a ConfigSpec. resolveEnv :: ConfigSpec cmd -> IO Config