-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Configuration management library -- -- Library to abstract the parsing of many haskell config values from -- different config sources @package conferer @version 1.0.0.0 -- | Internal module for Key related features module Conferer.Key.Internal -- | This type is used extensivelly as a way to point into a Source -- and in turn into a Config. The intended way to create them is -- is using mkKey. -- -- It's a list of alphanumeric words and each Source can interpret -- it as it sees fit. newtype Key Key :: [Text] -> Key [unKey] :: Key -> [Text] -- | Helper function to create Keys, this function always works, but -- since Keys reject some string this function transforms the -- input to provide lawful Keys instead of throwing. -- -- For example: -- --
--   'mkKey' "sOmE.KEy" == "some.key"
--   'mkKey' "1.key" == "1.key"
--   'mkKey' "1_thing.key" == "1thing.key"
--   'mkKey' "some....key" == "some.key"
--   'mkKey' ".." == ""
--   
mkKey :: String -> Key -- | Same as mkKey but for Text fromText :: Text -> Key -- | Collapse a key into a textual representation keyName :: Key -> Text -- | This function tells if a key is a subkey of another key based using -- key fragments instead of letters as units -- --
--   'isKeyPrefixOf' "foo" "foo.bar" == True
--   'isKeyPrefixOf' "foo" "foo" == True
--   'isKeyPrefixOf' "foo" "fooa" == False
--   
isKeyPrefixOf :: Key -> Key -> Bool -- | Given k1 and k2 this function drops k1 as a prefix from k2, if k1 is -- not a prefix of k2 it returns Nothing -- --
--   'keyPrefixOf' "foo" "foo.bar" == Just "bar"
--   'keyPrefixOf' "foo" "foo" == Just ""
--   'keyPrefixOf' "foo" "fooa" == Nothing
--   'keyPrefixOf' "" k == Just k
--   
stripKeyPrefix :: Key -> Key -> Maybe Key -- | Concatenate two keys (/.) :: Key -> Key -> Key -- | Get raw components from a key, usually to do some manipulation rawKeyComponents :: Key -> [Text] -- | Get first component of a key and the rest of the key unconsKey :: Key -> Maybe (Text, Key) instance GHC.Classes.Ord Conferer.Key.Internal.Key instance GHC.Classes.Eq Conferer.Key.Internal.Key instance GHC.Show.Show Conferer.Key.Internal.Key instance Data.String.IsString Conferer.Key.Internal.Key -- | Public API for Key related features module Conferer.Key -- | This type is used extensivelly as a way to point into a Source -- and in turn into a Config. The intended way to create them is -- is using mkKey. -- -- It's a list of alphanumeric words and each Source can interpret -- it as it sees fit. data Key -- | Helper function to create Keys, this function always works, but -- since Keys reject some string this function transforms the -- input to provide lawful Keys instead of throwing. -- -- For example: -- --
--   'mkKey' "sOmE.KEy" == "some.key"
--   'mkKey' "1.key" == "1.key"
--   'mkKey' "1_thing.key" == "1thing.key"
--   'mkKey' "some....key" == "some.key"
--   'mkKey' ".." == ""
--   
mkKey :: String -> Key -- | Same as mkKey but for Text fromText :: Text -> Key -- | Concatenate two keys (/.) :: Key -> Key -> Key -- | Given k1 and k2 this function drops k1 as a prefix from k2, if k1 is -- not a prefix of k2 it returns Nothing -- --
--   'keyPrefixOf' "foo" "foo.bar" == Just "bar"
--   'keyPrefixOf' "foo" "foo" == Just ""
--   'keyPrefixOf' "foo" "fooa" == Nothing
--   'keyPrefixOf' "" k == Just k
--   
stripKeyPrefix :: Key -> Key -> Maybe Key -- | This function tells if a key is a subkey of another key based using -- key fragments instead of letters as units -- --
--   'isKeyPrefixOf' "foo" "foo.bar" == True
--   'isKeyPrefixOf' "foo" "foo" == True
--   'isKeyPrefixOf' "foo" "fooa" == False
--   
isKeyPrefixOf :: Key -> Key -> Bool -- | Get raw components from a key, usually to do some manipulation rawKeyComponents :: Key -> [Text] -- | Get first component of a key and the rest of the key unconsKey :: Key -> Maybe (Text, Key) -- | Internal module for Key related features module Conferer.Source.Internal -- | Concrete type for IsSource data Source Source :: s -> Source -- | Main interface for interacting with external systems that provide -- configuration which will be used by FromConfig to fetch values. class IsSource s -- | This function is used by the Config to get values from this -- Source. getKeyInSource :: IsSource s => s -> Key -> IO (Maybe Text) -- | This function is used by the Config to list possible values -- from the Source that if the user getKeyInSource, it will -- be found. getSubkeysInSource :: IsSource s => s -> Key -> IO [Key] instance GHC.Show.Show Conferer.Source.Internal.Source instance Conferer.Source.Internal.IsSource Conferer.Source.Internal.Source -- | Core types for Config (here because of depedency cycles) module Conferer.Config.Internal.Types -- | This type acts as the entry point for most of the library, it's main -- purpouse is to expose a uniform interface into multiple configuration -- sources (such as env vars, cli args, and many others including use -- defined ones using the Source interface) data Config Config :: [Source] -> Map Key Dynamic -> [(Key, Key)] -> Config [configSources] :: Config -> [Source] [configDefaults] :: Config -> Map Key Dynamic [configKeyMappings] :: Config -> [(Key, Key)] -- | Result of a key lookup in a Config data KeyLookupResult MissingKey :: [Key] -> KeyLookupResult FoundInSources :: Key -> Text -> KeyLookupResult FoundInDefaults :: Key -> Dynamic -> KeyLookupResult -- | The type for creating a source given a Config, some sources -- require a certain configuration to be initialized (for example: the -- redis source needs connection info to connect to the server) type SourceCreator = Config -> IO Source instance GHC.Show.Show Conferer.Config.Internal.Types.Config instance GHC.Show.Show Conferer.Config.Internal.Types.KeyLookupResult -- | Public API module for Source related features module Conferer.Source -- | Concrete type for IsSource data Source Source :: s -> Source -- | Main interface for interacting with external systems that provide -- configuration which will be used by FromConfig to fetch values. class IsSource s -- | This function is used by the Config to get values from this -- Source. getKeyInSource :: IsSource s => s -> Key -> IO (Maybe Text) -- | This function is used by the Config to list possible values -- from the Source that if the user getKeyInSource, it will -- be found. getSubkeysInSource :: IsSource s => s -> Key -> IO [Key] -- | The type for creating a source given a Config, some sources -- require a certain configuration to be initialized (for example: the -- redis source needs connection info to connect to the server) type SourceCreator = Config -> IO Source -- | In memory source mostly used for testing module Conferer.Source.InMemory -- | A Source mostly use for mocking which is configured directly -- using a Map newtype InMemorySource InMemorySource :: Map Key Text -> InMemorySource [configMap] :: InMemorySource -> Map Key Text -- | Create a SourceCreator from a list of associations fromConfig :: [(Key, Text)] -> SourceCreator -- | Create a Source from a Map fromMap :: Map Key Text -> Source -- | Create a Source from a list of associations fromAssociations :: [(Key, Text)] -> Source instance GHC.Classes.Eq Conferer.Source.InMemory.InMemorySource instance GHC.Show.Show Conferer.Source.InMemory.InMemorySource instance Conferer.Source.Internal.IsSource Conferer.Source.InMemory.InMemorySource -- | Environment based source module Conferer.Source.Env -- | Source that interfaces with the environment transforming keys by -- uppercasing and interspersing underscores, and using a prefix to avoid -- clashing with system env vars -- -- so with "app" prefix, "some.key" turns into -- APP_SOME_KEY data EnvSource EnvSource :: RawEnvironment -> Prefix -> Source -> EnvSource [environment] :: EnvSource -> RawEnvironment [keyPrefix] :: EnvSource -> Prefix [innerSource] :: EnvSource -> Source -- | Type alias for the environment type RawEnvironment = [(String, String)] -- | Type alias for the env vars prefix type Prefix = Text -- | Create a SourceCreator using fromEnv fromConfig :: Prefix -> SourceCreator -- | Create a Source using the real environment fromEnv :: Prefix -> IO Source -- | Create a Source using a hardcoded list of env vars fromEnvList :: RawEnvironment -> Prefix -> Source -- | Get the env name from a prefix and a key by uppercasing and -- intercalating underscores keyToEnvVar :: Prefix -> Key -> Text -- | The opossite of keyToEnvVar envVarToKey :: Prefix -> Text -> Maybe Key instance GHC.Show.Show Conferer.Source.Env.EnvSource instance Conferer.Source.Internal.IsSource Conferer.Source.Env.EnvSource -- | Command line arguments based source module Conferer.Source.CLIArgs -- | This source provides keys from the command line arguments passed into -- the program. It only accepts arguments with -- and an equals, -- for example: ./awesomeapp --warp.port=5000 data CLIArgsSource CLIArgsSource :: RawCLIArgs -> Source -> CLIArgsSource [originalCliArgs] :: CLIArgsSource -> RawCLIArgs [innerSource] :: CLIArgsSource -> Source -- | Type alias for cli args type RawCLIArgs = [String] -- | Create a SourceCreator using fromEnv fromConfig :: SourceCreator -- | Create a Source using fromArgs but using real cli args fromEnv :: IO Source -- | Create a Source using cli args passed as parameter fromArgs :: RawCLIArgs -> Source -- | Parse an argument list into a dictionary suitable for a Source parseArgsIntoKeyValue :: [String] -> [(Key, Text)] instance GHC.Show.Show Conferer.Source.CLIArgs.CLIArgsSource instance Conferer.Source.Internal.IsSource Conferer.Source.CLIArgs.CLIArgsSource -- | Internal module providing Config functionality module Conferer.Config.Internal -- | This function runs lookups on the Config, first in -- Sources in order and then on the Dynamic based defaults. getKey :: Key -> Config -> IO KeyLookupResult -- | Alias for a mapping from one key to another used for transforming keys type KeyMapping = (Key, Key) -- | A key that has been transformed using one or many KeyMappings, -- so that that process can be reversed. data MappedKey MappedKey :: [KeyMapping] -> Key -> MappedKey [mappingsChain] :: MappedKey -> [KeyMapping] [mappedKey] :: MappedKey -> Key -- | This function lists all available keys under some key, that could be -- fetched successfully. listSubkeys :: Key -> Config -> IO [Key] -- | This function lists subkeys in some Sources and combines the -- results listRawSubkeysInSources :: Key -> [Source] -> IO [Key] -- | This function reverses the mappings in a MappedKey to retrieve -- the original key. -- -- Assumes that mappings were really used, otherwise it ignores bad -- values undoMappings :: MappedKey -> Key -- | This utility function run a list of IO actions and returns the first -- that return a Just, if no one does, returns Nothing untilJust :: [IO (Maybe a)] -> IO (Maybe a) -- | This function tries to apply a list of mappings to a key meaning -- replace the prefix with the new value from the mapping, if the mapping -- isn't a prefix that mapping is ignored -- -- This function always terminates even in presence of recursive -- mappings, since it removes the mapping after it was first used, and -- that causes that eventually the function will run out of keymappings -- and terminate. getKeysFromMappings :: [KeyMapping] -> Key -> [MappedKey] -- | This utility function splits a list based on a cond function -- and returns a tuple of previous value, next values and the mapped -- found value. findAndSplitList :: forall a b. (a -> Maybe b) -> [a] -> [([a], b, [a])] -- | This function gets a value from Sources but ignores mappings -- and defaults getRawKeyInSources :: Key -> Config -> IO (Maybe (Key, Text)) -- | This function gets values from the defaults getKeyFromDefaults :: Key -> Config -> Maybe Dynamic -- | The empty configuration, this Config is used as the base for -- most config creating functions. emptyConfig :: Config -- | This function adds some key mappings to a Config addKeyMappings :: [KeyMapping] -> Config -> Config -- | This function adds defaults to a Config addDefaults :: [(Key, Dynamic)] -> Config -> Config -- | This function adds one default of a custom type to a Config -- -- Note that unlike addDefaults this function does the toDyn so no -- need to do it on the user's side addDefault :: Typeable a => Key -> a -> Config -> Config -- | This function removes a key default from a Config removeDefault :: Key -> Config -> Config -- | Instantiate a Source using an SourceCreator and a -- Config and add to the config addSource :: SourceCreator -> Config -> IO Config instance GHC.Classes.Eq Conferer.Config.Internal.MappedKey instance GHC.Show.Show Conferer.Config.Internal.MappedKey -- | Internal module providing FromConfig functionality module Conferer.FromConfig.Internal -- | The typeclass for defining the way to get values from a Config, -- hiding the Text based nature of the Sources and parse -- whatever value as the types sees fit -- -- Some of these instances are provided in different packages to avoid -- the heavy dependencies. -- -- It provides a reasonable default using Generics so most of the -- time user need not to implement this typeclass. class FromConfig a -- | This function uses a Config and a scoping Key to get a -- value. -- -- Some conventions: -- -- fetchFromConfig :: FromConfig a => Key -> Config -> IO a -- | This function uses a Config and a scoping Key to get a -- value. -- -- Some conventions: -- -- fetchFromConfig :: (FromConfig a, Typeable a, Generic a, IntoDefaultsG (Rep a), FromConfigG (Rep a)) => Key -> Config -> IO a -- | Utility only typeclass to smooth the naming differences between -- default values for external library settings -- -- This typeclass is not used internally it's only here for convinience -- for users class DefaultConfig a configDef :: DefaultConfig a => a -- | A newtype wrapper for a FilePath to allow implementing -- FromConfig with something better than just a String newtype File File :: FilePath -> File -- | Helper function to parse a Bool from Text parseBool :: Text -> Maybe Bool -- | Helper function to implement fetchFromConfig using the Read -- instance fetchFromConfigByRead :: (Typeable a, Read a) => Key -> Config -> IO a -- | Helper function to implement fetchFromConfig using the IsString -- instance fetchFromConfigByIsString :: (Typeable a, IsString a) => Key -> Config -> IO a -- | Helper function to implement fetchFromConfig using some parsing -- function fetchFromConfigWith :: forall a. Typeable a => (Text -> Maybe a) -> Key -> Config -> IO a -- | Helper function does the plumbing of desconstructing a default into -- smaller defaults, which is usefull for nested fetchFromConfig. addDefaultsAfterDeconstructingToDefaults :: forall a. Typeable a => (a -> [(Key, Dynamic)]) -> Key -> Config -> IO Config -- | Exception to show that a value couldn't be parsed properly data ConfigParsingError ConfigParsingError :: Key -> Text -> TypeRep -> ConfigParsingError -- | Helper function to throw ConfigParsingError throwConfigParsingError :: forall a b. Typeable a => Key -> Text -> IO b -- | Helper function to create a ConfigParsingError configParsingError :: forall a. Typeable a => Key -> Text -> ConfigParsingError -- | Exception to show that some non optional Key was missing while -- trying to fetchFromConfig data MissingRequiredKey MissingRequiredKey :: [Key] -> TypeRep -> MissingRequiredKey -- | Simplified helper function to throw a MissingRequiredKey throwMissingRequiredKey :: forall t a. Typeable t => Key -> IO a -- | Simplified helper function to create a MissingRequiredKey missingRequiredKey :: forall t. Typeable t => Key -> MissingRequiredKey -- | Helper function to throw a MissingRequiredKey throwMissingRequiredKeys :: forall t a. Typeable t => [Key] -> IO a -- | Helper function to create a MissingRequiredKey missingRequiredKeys :: forall a. Typeable a => [Key] -> MissingRequiredKey -- | Exception to show that the provided default had the wrong type, this -- is usually a programmer error and a user that configures the library -- can not do much to fix it. data TypeMismatchWithDefault TypeMismatchWithDefault :: Key -> Dynamic -> TypeRep -> TypeMismatchWithDefault -- | Helper function to throw a TypeMismatchWithDefault throwTypeMismatchWithDefault :: forall a b. Typeable a => Key -> Dynamic -> IO b -- | Helper function to create a TypeMismatchWithDefault typeMismatchWithDefault :: forall a. Typeable a => Key -> Dynamic -> TypeMismatchWithDefault -- | Fetch from value from the defaults map of a Config or else -- throw fetchRequiredFromDefaults :: forall a. Typeable a => Key -> Config -> IO a -- | Fetch from value from the defaults map of a Config or else -- return a Nothing fetchFromDefaults :: forall a. Typeable a => Key -> Config -> IO (Maybe a) -- | Same as fetchFromConfig using the root key fetchFromRootConfig :: forall a. FromConfig a => Config -> IO a -- | Same as fetchFromConfig but adding a user defined default -- before fetchFromConfiging so it doesn't throw a MissingKeyError fetchFromConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Config -> Key -> a -> IO a -- | Same as fetchFromConfigWithDefault using the root key fetchFromRootConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Config -> a -> IO a -- | Purely Generics machinery, ignore... class FromConfigG f fetchFromConfigG :: FromConfigG f => Key -> Config -> IO (f a) -- | Purely Generics machinery, ignore... class FromConfigWithConNameG f fetchFromConfigWithConNameG :: FromConfigWithConNameG f => String -> Key -> Config -> IO (f a) -- | Purely Generics machinery, ignore... class IntoDefaultsG f intoDefaultsG :: IntoDefaultsG f => Key -> f a -> [(Key, Dynamic)] -- | Purely Generics machinery, ignore... class IntoDefaultsWithConNameG f intoDefaultsWithConNameG :: IntoDefaultsWithConNameG f => String -> Key -> f a -> [(Key, Dynamic)] instance GHC.Read.Read Conferer.FromConfig.Internal.File instance GHC.Classes.Ord Conferer.FromConfig.Internal.File instance GHC.Classes.Eq Conferer.FromConfig.Internal.File instance GHC.Show.Show Conferer.FromConfig.Internal.File instance GHC.Classes.Eq Conferer.FromConfig.Internal.ConfigParsingError instance GHC.Classes.Eq Conferer.FromConfig.Internal.MissingRequiredKey instance (Conferer.FromConfig.Internal.IntoDefaultsWithConNameG inner, GHC.Generics.Constructor constructor) => Conferer.FromConfig.Internal.IntoDefaultsG (GHC.Generics.C1 constructor inner) instance (Conferer.FromConfig.Internal.IntoDefaultsWithConNameG left, Conferer.FromConfig.Internal.IntoDefaultsWithConNameG right) => Conferer.FromConfig.Internal.IntoDefaultsWithConNameG (left GHC.Generics.:*: right) instance (Conferer.FromConfig.Internal.IntoDefaultsG inner, GHC.Generics.Selector selector) => Conferer.FromConfig.Internal.IntoDefaultsWithConNameG (GHC.Generics.S1 selector inner) instance Data.Typeable.Internal.Typeable a => Conferer.FromConfig.Internal.FromConfig a instance Conferer.FromConfig.Internal.FromConfig () instance Conferer.FromConfig.Internal.FromConfig GHC.Base.String instance (Data.Typeable.Internal.Typeable a, Conferer.FromConfig.Internal.FromConfig a) => Conferer.FromConfig.Internal.FromConfig [a] instance Conferer.FromConfig.Internal.FromConfig GHC.Types.Int instance Conferer.FromConfig.Internal.FromConfig GHC.Integer.Type.Integer instance Conferer.FromConfig.Internal.FromConfig GHC.Types.Float instance Conferer.FromConfig.Internal.FromConfig Data.ByteString.Internal.ByteString instance Conferer.FromConfig.Internal.FromConfig Data.ByteString.Lazy.Internal.ByteString instance (Data.Typeable.Internal.Typeable a, Conferer.FromConfig.Internal.FromConfig a) => Conferer.FromConfig.Internal.FromConfig (GHC.Maybe.Maybe a) instance Conferer.FromConfig.Internal.FromConfig Data.Text.Internal.Text instance Conferer.FromConfig.Internal.FromConfig GHC.Types.Bool instance Conferer.FromConfig.Internal.FromConfig Conferer.FromConfig.Internal.File instance Conferer.FromConfig.Internal.FromConfig inner => Conferer.FromConfig.Internal.FromConfigG (GHC.Generics.Rec0 inner) instance Conferer.FromConfig.Internal.IntoDefaultsG inner => Conferer.FromConfig.Internal.IntoDefaultsG (GHC.Generics.D1 metadata inner) instance Data.Typeable.Internal.Typeable inner => Conferer.FromConfig.Internal.IntoDefaultsG (GHC.Generics.Rec0 inner) instance (Conferer.FromConfig.Internal.FromConfigWithConNameG inner, GHC.Generics.Constructor constructor) => Conferer.FromConfig.Internal.FromConfigG (GHC.Generics.C1 constructor inner) instance (Conferer.FromConfig.Internal.FromConfigWithConNameG left, Conferer.FromConfig.Internal.FromConfigWithConNameG right) => Conferer.FromConfig.Internal.FromConfigWithConNameG (left GHC.Generics.:*: right) instance (Conferer.FromConfig.Internal.FromConfigG inner, GHC.Generics.Selector selector) => Conferer.FromConfig.Internal.FromConfigWithConNameG (GHC.Generics.S1 selector inner) instance Conferer.FromConfig.Internal.FromConfigG inner => Conferer.FromConfig.Internal.FromConfigG (GHC.Generics.D1 metadata inner) instance GHC.Classes.Eq Conferer.FromConfig.Internal.TypeMismatchWithDefault instance GHC.Exception.Type.Exception Conferer.FromConfig.Internal.TypeMismatchWithDefault instance GHC.Show.Show Conferer.FromConfig.Internal.TypeMismatchWithDefault instance GHC.Exception.Type.Exception Conferer.FromConfig.Internal.MissingRequiredKey instance GHC.Show.Show Conferer.FromConfig.Internal.MissingRequiredKey instance GHC.Exception.Type.Exception Conferer.FromConfig.Internal.ConfigParsingError instance GHC.Show.Show Conferer.FromConfig.Internal.ConfigParsingError instance Data.String.IsString Conferer.FromConfig.Internal.File -- | Public API module providing FromConfig functionality module Conferer.FromConfig -- | The typeclass for defining the way to get values from a Config, -- hiding the Text based nature of the Sources and parse -- whatever value as the types sees fit -- -- Some of these instances are provided in different packages to avoid -- the heavy dependencies. -- -- It provides a reasonable default using Generics so most of the -- time user need not to implement this typeclass. class FromConfig a -- | This function uses a Config and a scoping Key to get a -- value. -- -- Some conventions: -- -- fetchFromConfig :: FromConfig a => Key -> Config -> IO a -- | This function uses a Config and a scoping Key to get a -- value. -- -- Some conventions: -- -- fetchFromConfig :: (FromConfig a, Typeable a, Generic a, IntoDefaultsG (Rep a), FromConfigG (Rep a)) => Key -> Config -> IO a -- | Utility only typeclass to smooth the naming differences between -- default values for external library settings -- -- This typeclass is not used internally it's only here for convinience -- for users class DefaultConfig a configDef :: DefaultConfig a => a -- | Same as fetchFromConfig but adding a user defined default -- before fetchFromConfiging so it doesn't throw a MissingKeyError fetchFromConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Config -> Key -> a -> IO a -- | Same as fetchFromConfig using the root key fetchFromRootConfig :: forall a. FromConfig a => Config -> IO a -- | Same as fetchFromConfigWithDefault using the root key fetchFromRootConfigWithDefault :: forall a. (Typeable a, FromConfig a) => Config -> a -> IO a -- | Helper function to implement fetchFromConfig using the IsString -- instance fetchFromConfigByIsString :: (Typeable a, IsString a) => Key -> Config -> IO a -- | Helper function to implement fetchFromConfig using the Read -- instance fetchFromConfigByRead :: (Typeable a, Read a) => Key -> Config -> IO a -- | Helper function to implement fetchFromConfig using some parsing -- function fetchFromConfigWith :: forall a. Typeable a => (Text -> Maybe a) -> Key -> Config -> IO a -- | Helper function does the plumbing of desconstructing a default into -- smaller defaults, which is usefull for nested fetchFromConfig. addDefaultsAfterDeconstructingToDefaults :: forall a. Typeable a => (a -> [(Key, Dynamic)]) -> Key -> Config -> IO Config -- | Exception to show that some non optional Key was missing while -- trying to fetchFromConfig data MissingRequiredKey -- | Simplified helper function to throw a MissingRequiredKey throwMissingRequiredKey :: forall t a. Typeable t => Key -> IO a -- | Simplified helper function to create a MissingRequiredKey missingRequiredKey :: forall t. Typeable t => Key -> MissingRequiredKey -- | Exception to show that a value couldn't be parsed properly data ConfigParsingError -- | Helper function to throw ConfigParsingError throwConfigParsingError :: forall a b. Typeable a => Key -> Text -> IO b -- | Helper function to create a ConfigParsingError configParsingError :: forall a. Typeable a => Key -> Text -> ConfigParsingError -- | Exception to show that the provided default had the wrong type, this -- is usually a programmer error and a user that configures the library -- can not do much to fix it. data TypeMismatchWithDefault -- | Helper function to throw a TypeMismatchWithDefault throwTypeMismatchWithDefault :: forall a b. Typeable a => Key -> Dynamic -> IO b -- | Helper function to create a TypeMismatchWithDefault typeMismatchWithDefault :: forall a. Typeable a => Key -> Dynamic -> TypeMismatchWithDefault -- | This type is used extensivelly as a way to point into a Source -- and in turn into a Config. The intended way to create them is -- is using mkKey. -- -- It's a list of alphanumeric words and each Source can interpret -- it as it sees fit. data Key -- | Concatenate two keys (/.) :: Key -> Key -> Key -- | A newtype wrapper for a FilePath to allow implementing -- FromConfig with something better than just a String newtype File File :: FilePath -> File -- | Result of a key lookup in a Config data KeyLookupResult MissingKey :: [Key] -> KeyLookupResult FoundInSources :: Key -> Text -> KeyLookupResult FoundInDefaults :: Key -> Dynamic -> KeyLookupResult -- | Fetch from value from the defaults map of a Config or else -- return a Nothing fetchFromDefaults :: forall a. Typeable a => Key -> Config -> IO (Maybe a) -- | Fetch from value from the defaults map of a Config or else -- throw fetchRequiredFromDefaults :: forall a. Typeable a => Key -> Config -> IO a -- | Public API providing Config functionality module Conferer.Config -- | This type acts as the entry point for most of the library, it's main -- purpouse is to expose a uniform interface into multiple configuration -- sources (such as env vars, cli args, and many others including use -- defined ones using the Source interface) data Config -- | This function runs lookups on the Config, first in -- Sources in order and then on the Dynamic based defaults. getKey :: Key -> Config -> IO KeyLookupResult -- | Result of a key lookup in a Config data KeyLookupResult MissingKey :: [Key] -> KeyLookupResult FoundInSources :: Key -> Text -> KeyLookupResult FoundInDefaults :: Key -> Dynamic -> KeyLookupResult -- | This function lists all available keys under some key, that could be -- fetched successfully. listSubkeys :: Key -> Config -> IO [Key] -- | The empty configuration, this Config is used as the base for -- most config creating functions. emptyConfig :: Config -- | Instantiate a Source using an SourceCreator and a -- Config and add to the config addSource :: SourceCreator -> Config -> IO Config -- | This function adds one default of a custom type to a Config -- -- Note that unlike addDefaults this function does the toDyn so no -- need to do it on the user's side addDefault :: Typeable a => Key -> a -> Config -> Config -- | This function adds defaults to a Config addDefaults :: [(Key, Dynamic)] -> Config -> Config -- | This function adds some key mappings to a Config addKeyMappings :: [KeyMapping] -> Config -> Config -- | & is a reverse application operator. This provides -- notational convenience. Its precedence is one higher than that of the -- forward application operator $, which allows & to be -- nested in $. -- --
--   >>> 5 & (+1) & show
--   "6"
--   
(&) :: a -> (a -> b) -> b infixl 1 & -- | Public API module providing some helper functions related to files module Conferer.Source.Files -- | Helper function to get a file from the config specifying the extension -- and using current env getFilePathFromEnv :: Key -> String -> Config -> IO FilePath -- | Source that namespaces an inner source module Conferer.Source.Namespaced -- | This source takes a source and returns a new source that always checks -- that the Key given always starts with certain Key and -- then strips that prefix before consulting its inner Source data NamespacedSource NamespacedSource :: Key -> Source -> NamespacedSource [scopeKey] :: NamespacedSource -> Key [innerSource] :: NamespacedSource -> Source -- | Create a SourceCreator from a prefix and another -- SourceCreator fromConfig :: Key -> SourceCreator -> SourceCreator -- | Create a Source from a prefix and another Source fromInner :: Key -> Source -> Source instance GHC.Show.Show Conferer.Source.Namespaced.NamespacedSource instance Conferer.Source.Internal.IsSource Conferer.Source.Namespaced.NamespacedSource -- | Do nothing source module Conferer.Source.Null -- | Stub source that has no keys data NullSource NullSource :: NullSource -- | Create SourceCreator fromConfig :: SourceCreator -- | Create a Source empty :: Source instance GHC.Classes.Eq Conferer.Source.Null.NullSource instance GHC.Show.Show Conferer.Source.Null.NullSource instance Conferer.Source.Internal.IsSource Conferer.Source.Null.NullSource -- | Properties file source module Conferer.Source.PropertiesFile -- | Source that uses a config file in -- config/{env}.properties and parses it as a properties file -- with some.key=a value lines data PropertiesFileSource PropertiesFileSource :: FilePath -> Source -> PropertiesFileSource [originalFilePath] :: PropertiesFileSource -> FilePath [innerSource] :: PropertiesFileSource -> Source -- | Create a SourceCreator using getFilePathFromEnv to get -- the path to file and fromFilePath fromConfig :: Key -> SourceCreator -- | Create a Source reading the file and using that as a properties -- file, but if the file doesn't exist do nothing. fromFilePath :: FilePath -> IO Source -- | Create a Source using some content as a properties file fromFileContent :: FilePath -> Text -> Source -- | Transform a line into a key/value pair (or not) lineToKeyValue :: Text -> Maybe (Key, Text) instance GHC.Show.Show Conferer.Source.PropertiesFile.PropertiesFileSource instance Conferer.Source.Internal.IsSource Conferer.Source.PropertiesFile.PropertiesFileSource -- | Public and stable API for the most basic usage of this library module Conferer -- | Create a Config which reads from command line arguments, env -- vars and property files that depend on the environment -- (config/development.properties) by default mkConfig :: Text -> IO Config -- | Use the FromConfig instance to get a value of type a -- from the config using some default fallback. The most common use for -- this is creating a custom record and using this function to fetch it -- at initialization time. -- -- This function throws only parsing exceptions when the values are -- present but malformed somehow ("abc" as an Int) but that -- depends on the FromConfig implementation for the type. fetch :: forall a. (FromConfig a, Typeable a, DefaultConfig a) => Config -> IO a -- | Same as fetch but it accepts the default as a parameter instead -- of using the default from configDef fetch' :: forall a. (FromConfig a, Typeable a) => Config -> a -> IO a -- | Same as fetch' but you can specify a Key instead of the -- root key which allows you to fetch smaller values when you need them -- instead of a big one at initialization time. fetchKey :: forall a. (FromConfig a, Typeable a) => Config -> Key -> a -> IO a -- | Same as fetchKey but it returns a Nothing when the value -- isn't present safeFetchKey :: forall a. (FromConfig a, Typeable a) => Config -> Key -> IO (Maybe a) -- | Same as fetchKey but it throws when the value isn't present. unsafeFetchKey :: forall a. FromConfig a => Config -> Key -> IO a -- | Utility only typeclass to smooth the naming differences between -- default values for external library settings -- -- This typeclass is not used internally it's only here for convinience -- for users class DefaultConfig a configDef :: DefaultConfig a => a -- | The typeclass for defining the way to get values from a Config, -- hiding the Text based nature of the Sources and parse -- whatever value as the types sees fit -- -- Some of these instances are provided in different packages to avoid -- the heavy dependencies. -- -- It provides a reasonable default using Generics so most of the -- time user need not to implement this typeclass. class FromConfig a -- | This type acts as the entry point for most of the library, it's main -- purpouse is to expose a uniform interface into multiple configuration -- sources (such as env vars, cli args, and many others including use -- defined ones using the Source interface) data Config -- | This type is used extensivelly as a way to point into a Source -- and in turn into a Config. The intended way to create them is -- is using mkKey. -- -- It's a list of alphanumeric words and each Source can interpret -- it as it sees fit. data Key -- | Some testing utilities module Conferer.Test -- | Create a Config mostly used for testing FromConfig instances -- without having to create a full config configWith :: [(Key, Dynamic)] -> [(Key, Text)] -> IO Config