etc-0.4.1.0: Declarative configuration spec for Haskell projects

Safe HaskellNone
LanguageHaskell2010

System.Etc.Internal.Types

Documentation

class IConfig config where #

Methods

getConfigValue #

Arguments

:: (MonadThrow m, FromJSON result) 
=> [Text]

Key to fetch from config map

-> config

Config record

-> m result 

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

getConfigValueWith #

Arguments

:: MonadThrow m 
=> (Value -> Parser result)

JSON Parser function

-> [Text]

Key to fetch from config map

-> config

Config record

-> 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 {...})

getAllConfigSources :: MonadThrow m => [Text] -> config -> m (Set ConfigSource) #

getSelectedConfigSource :: MonadThrow m => [Text] -> config -> m ConfigSource #

Instances
IConfig Config # 
Instance details

Defined in System.Etc.Internal.Config

Methods

getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> Config -> m result #

getConfigValueWith :: MonadThrow m => (Value -> Parser result) -> [Text] -> Config -> m result #

getAllConfigSources :: MonadThrow m => [Text] -> Config -> m (Set ConfigSource) #

getSelectedConfigSource :: MonadThrow m => [Text] -> Config -> m ConfigSource #

newtype Config #

Constructors

Config 
Instances
Eq Config # 
Instance details

Defined in System.Etc.Internal.Types

Methods

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

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

Show Config # 
Instance details

Defined in System.Etc.Internal.Types

Semigroup Config # 
Instance details

Defined in System.Etc.Internal.Types

Monoid Config # 
Instance details

Defined in System.Etc.Internal.Types

IConfig Config # 
Instance details

Defined in System.Etc.Internal.Config

Methods

getConfigValue :: (MonadThrow m, FromJSON result) => [Text] -> Config -> m result #

getConfigValueWith :: MonadThrow m => (Value -> Parser result) -> [Text] -> Config -> m result #

getAllConfigSources :: MonadThrow m => [Text] -> Config -> m (Set ConfigSource) #

getSelectedConfigSource :: MonadThrow m => [Text] -> Config -> m ConfigSource #

data Value a #

Constructors

Plain 

Fields

Sensitive 

Fields

Instances
Functor Value # 
Instance details

Defined in System.Etc.Internal.Types

Methods

fmap :: (a -> b) -> Value a -> Value b #

(<$) :: a -> Value b -> Value a #

Applicative Value # 
Instance details

Defined in System.Etc.Internal.Types

Methods

pure :: a -> Value a #

(<*>) :: Value (a -> b) -> Value a -> Value b #

liftA2 :: (a -> b -> c) -> Value a -> Value b -> Value c #

(*>) :: Value a -> Value b -> Value b #

(<*) :: Value a -> Value b -> Value a #

Eq a => Eq (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

Methods

(==) :: Value a -> Value a -> Bool #

(/=) :: Value a -> Value a -> Bool #

Ord a => Ord (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

Methods

compare :: Value a -> Value a -> Ordering #

(<) :: Value a -> Value a -> Bool #

(<=) :: Value a -> Value a -> Bool #

(>) :: Value a -> Value a -> Bool #

(>=) :: Value a -> Value a -> Bool #

max :: Value a -> Value a -> Value a #

min :: Value a -> Value a -> Value a #

Show a => Show (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

Methods

showsPrec :: Int -> Value a -> ShowS #

show :: Value a -> String #

showList :: [Value a] -> ShowS #

IsString a => IsString (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

Methods

fromString :: String -> Value a #

Generic (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

Associated Types

type Rep (Value a) :: * -> * #

Methods

from :: Value a -> Rep (Value a) x #

to :: Rep (Value a) x -> Value a #

type Rep (Value a) # 
Instance details

Defined in System.Etc.Internal.Types

type Rep (Value a) = D1 (MetaData "Value" "System.Etc.Internal.Types" "etc-0.4.1.0-6zWhfl1CPDA6SFV459GKee" False) (C1 (MetaCons "Plain" PrefixI True) (S1 (MetaSel (Just "fromValue") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a)) :+: C1 (MetaCons "Sensitive" PrefixI True) (S1 (MetaSel (Just "fromValue") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a)))

filterMaybe :: (a -> Bool) -> Maybe a -> Maybe a #

data ConfigValueType #

Instances
Eq ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Read ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Show ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Generic ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Associated Types

type Rep ConfigValueType :: * -> * #

Lift ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Methods

lift :: ConfigValueType -> Q Exp #

FromJSON ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Parser

Display ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types

type Rep ConfigValueType # 
Instance details

Defined in System.Etc.Internal.Spec.Types