Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data Provider = Provider {
- getKeyInProvider :: Key -> IO (Maybe Text)
- newtype Key = Path {}
- keyName :: Key -> Text
- data Config = Config {}
- type ProviderCreator = Config -> IO Provider
- class FetchFromConfig a where
- class DefaultConfig a where
- configDef :: a
- class Typeable a => UpdateFromConfig a where
- updateFromConfig :: Key -> Config -> a -> IO a
- class UpdateFromConfigG f where
- updateFromConfigG :: Key -> Config -> f a -> IO (f a)
- data ConfigParsingError = ConfigParsingError Key Text TypeRep
- data FailedToFetchError = FailedToFetchError Key TypeRep
Documentation
Core interface for library provided configuration, basically consists of
getting a Key
and informing returning a maybe signaling the value and
if it's present in that specific provider
The way to index Provider
s, basically list of names that will be adapted
to whatever the provider needs
Core type that the user of this library interact with, in the future it may contain more this besides a list of providers
type ProviderCreator = Config -> IO Provider Source #
The type for creating a provider given a Config
, some providers require a
certain configuration to be initialized (for example: the redis provider
needs connection info to connect to the server)
class FetchFromConfig a where Source #
Main typeclass for defining the way to get values from config, hiding the
Text
based nature of the Provider
s
Here a Nothing
means that the value didn't appear in the config, some
instances never return a value since they have defaults that can never
fail
Nothing
fetch :: Key -> Config -> IO (Maybe a) Source #
fetch :: (DefaultConfig a, UpdateFromConfig a) => Key -> Config -> IO (Maybe a) Source #
Instances
class DefaultConfig a where Source #
Here implementing this typeclass means that this type has some kind of default that is both always valid and has always the same semantics, for example: Warp.Settings has a default since it's always use in the same way (to configure a warp server) but for example an Int could mean many things depending on the context so it doesn't really make sense to implement it for it
It's also used for the Generic
implementation, if you have a Record made up from
types that implement FetchFromConfig
you can derive the FetchFromConfig
automatically
by implementing DefaultConfig
and deriving (using Generic
) UpdateFromConfig
class Typeable a => UpdateFromConfig a where Source #
This class only exist for the Generics
machinery, it means that a value can get
updated using a config, so for example a Warp.Settings can get updated from a config,
but that doesn't make much sense for something like an Int
You'd normally would never implement this typeclass, if you want to implement
FetchFromConfig
you should implement that directly, and if you want to use
DefaultConfig
and UpdateFromConfig
to implement FetchFromConfig
you should let
the default Generics
based implementation do it's thing
Nothing
updateFromConfig :: Key -> Config -> a -> IO a Source #
updateFromConfig :: (Generic a, UpdateFromConfigG (Rep a), DefaultConfig a) => Key -> Config -> a -> IO a Source #
class UpdateFromConfigG f where Source #
Purely Generics
machinery, ignore...
Instances
FetchFromConfig inner => UpdateFromConfigG (Rec0 inner) Source # | Purely |
Defined in Conferer.FetchFromConfig.Basics | |
UpdateFromConfigG inner => UpdateFromConfigG (D1 metadata inner) Source # | |
Defined in Conferer.FetchFromConfig.Basics | |
(UpdateFromConfigWithConNameG inner, Constructor constructor) => UpdateFromConfigG (C1 constructor inner) Source # | |
Defined in Conferer.FetchFromConfig.Basics |
data ConfigParsingError Source #
Instances
Eq ConfigParsingError Source # | |
Defined in Conferer.Types (==) :: ConfigParsingError -> ConfigParsingError -> Bool # (/=) :: ConfigParsingError -> ConfigParsingError -> Bool # | |
Show ConfigParsingError Source # | |
Defined in Conferer.Types showsPrec :: Int -> ConfigParsingError -> ShowS # show :: ConfigParsingError -> String # showList :: [ConfigParsingError] -> ShowS # | |
Exception ConfigParsingError Source # | |
Defined in Conferer.Types |
data FailedToFetchError Source #
Instances
Eq FailedToFetchError Source # | |
Defined in Conferer.Types (==) :: FailedToFetchError -> FailedToFetchError -> Bool # (/=) :: FailedToFetchError -> FailedToFetchError -> Bool # | |
Show FailedToFetchError Source # | |
Defined in Conferer.Types showsPrec :: Int -> FailedToFetchError -> ShowS # show :: FailedToFetchError -> String # showList :: [FailedToFetchError] -> ShowS # | |
Exception FailedToFetchError Source # | |
Defined in Conferer.Types |