etc-0.4.1.0: Declarative configuration spec for Haskell projects

Safe HaskellNone
LanguageHaskell2010

System.Etc.Internal.Types

Documentation

class IConfig config where Source #

Methods

getConfigValue Source #

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 Source #

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) Source #

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

Instances
IConfig Config Source # 
Instance details

Defined in System.Etc.Internal.Config

newtype Config Source #

Constructors

Config 
Instances
Eq Config Source # 
Instance details

Defined in System.Etc.Internal.Types

Methods

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

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

Show Config Source # 
Instance details

Defined in System.Etc.Internal.Types

Semigroup Config Source # 
Instance details

Defined in System.Etc.Internal.Types

Monoid Config Source # 
Instance details

Defined in System.Etc.Internal.Types

IConfig Config Source # 
Instance details

Defined in System.Etc.Internal.Config

data Value a Source #

Constructors

Plain 

Fields

Sensitive 

Fields

Instances
Functor Value Source # 
Instance details

Defined in System.Etc.Internal.Types

Methods

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

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

Applicative Value Source # 
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) Source # 
Instance details

Defined in System.Etc.Internal.Types

Methods

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

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

Ord a => Ord (Value a) Source # 
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) Source # 
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) Source # 
Instance details

Defined in System.Etc.Internal.Types

Methods

fromString :: String -> Value a #

Generic (Value a) Source # 
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) Source # 
Instance details

Defined in System.Etc.Internal.Types

type Rep (Value a) = D1 (MetaData "Value" "System.Etc.Internal.Types" "etc-0.4.1.0-7q0W6i0k47BIqxo3Mr9o9p" 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 Source #

data ConfigValueType Source #

Instances
Eq ConfigValueType Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Read ConfigValueType Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Show ConfigValueType Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Generic ConfigValueType Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types

Associated Types

type Rep ConfigValueType :: * -> * #

Lift ConfigValueType Source # 
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 Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types

type Rep ConfigValueType Source # 
Instance details

Defined in System.Etc.Internal.Spec.Types