conferer-0.2.0.0: Configuration management library

Safe HaskellSafe
LanguageHaskell2010

Conferer.Types

Synopsis

Documentation

data Provider Source #

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

Constructors

Provider 

Fields

newtype Key Source #

The way to index Providers, basically list of names that will be adapted to whatever the provider needs

Constructors

Path 

Fields

Instances
Eq Key Source # 
Instance details

Defined in Conferer.Types

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Ord Key Source # 
Instance details

Defined in Conferer.Types

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Show Key Source # 
Instance details

Defined in Conferer.Types

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

IsString Key Source # 
Instance details

Defined in Conferer.Types

Methods

fromString :: String -> Key #

keyName :: Key -> Text Source #

Collapse a key into a textual representation

data Config Source #

Core type that the user of this library interact with, in the future it may contain more this besides a list of providers

Constructors

Config 

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 Providers

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

Minimal complete definition

Nothing

Methods

fetch :: Key -> Config -> IO (Maybe a) Source #

fetch :: (DefaultConfig a, UpdateFromConfig a) => Key -> Config -> IO (Maybe a) Source #

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

Methods

configDef :: a Source #

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

Minimal complete definition

Nothing

class UpdateFromConfigG f where Source #

Purely Generics machinery, ignore...

Methods

updateFromConfigG :: Key -> Config -> f a -> IO (f a) Source #

Instances
FetchFromConfig inner => UpdateFromConfigG (Rec0 inner) Source #

Purely Generics machinery, ignore...

Instance details

Defined in Conferer.FetchFromConfig.Basics

Methods

updateFromConfigG :: Key -> Config -> Rec0 inner a -> IO (Rec0 inner a) Source #

UpdateFromConfigG inner => UpdateFromConfigG (D1 metadata inner) Source # 
Instance details

Defined in Conferer.FetchFromConfig.Basics

Methods

updateFromConfigG :: Key -> Config -> D1 metadata inner a -> IO (D1 metadata inner a) Source #

(UpdateFromConfigWithConNameG inner, Constructor constructor) => UpdateFromConfigG (C1 constructor inner) Source # 
Instance details

Defined in Conferer.FetchFromConfig.Basics

Methods

updateFromConfigG :: Key -> Config -> C1 constructor inner a -> IO (C1 constructor inner a) Source #