cfg-0.0.2.2: Type directed application configuration parsing and accessors
Copyright© Jonathan Lorimer 2023
LicenseMIT
Maintainerjonathanlorimer@pm.me
Stabilitystable
Safe HaskellNone
LanguageHaskell2010

Cfg.Deriving.KeyModifier

Description

This module provides type level tags that can be used to configure string transformations against configuration keys derived from things like record fields.

Since: 0.0.2.0

Synopsis

Key Modifiers

class KeyModifier (t :: k) where Source #

This typeclass turns a type level "tag" into a function from Text -> Text. In addition to the instances for the "tags", there are also instances for type level lists and tuples up to an arity of 4.

important: For type level lists and tuples the modifiers are applied in order from left to right.

>>> getKeyModifier @'[ToUpper, ToLower] "Hello World"
"hello world"
>>> getKeyModifier @(ToLower, ToUpper) "Hello World"
"HELLO WORLD"
>>> getKeyModifier @CamelToSnake "iLoveCFGProject"
"i_love_cfg_project"

Since: 0.0.2.0

Instances

Instances details
KeyModifier '() Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier Identity Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier LowerFirst Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier ToLower Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier ToUpper Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier UpperFirst Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KnownChar separator => KeyModifier (CamelTo separator :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KnownSymbol prefix => KeyModifier (StripPrefix prefix :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KnownSymbol prefix => KeyModifier (StripSuffix prefix :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

(KeyModifier a, KeyModifier b) => KeyModifier ((a, b) :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

(KeyModifier a, KeyModifier b, KeyModifier c) => KeyModifier ((a, b, c) :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

(KeyModifier a, KeyModifier b, KeyModifier c, KeyModifier d) => KeyModifier ((a, b, c, d) :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier ('[] :: [a]) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier k => KeyModifier ('ConstructorName k :: RootKey a) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

KeyModifier k => KeyModifier ('TypeName k :: RootKey a) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

(KeyModifier a2, KeyModifier as) => KeyModifier (a2 ': as :: [a1]) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data Identity Source #

Identity transformation, corresponds to id, does not change the string.

Since: 0.0.2.0

Instances

Instances details
KeyModifier Identity Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data ToLower Source #

Lower cases all alphabetical characters, corresponds to toLower.

Since: 0.0.2.0

Instances

Instances details
KeyModifier ToLower Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data ToUpper Source #

Upper cases all alphabetical characters, corresponds to toUpper.

Since: 0.0.2.0

Instances

Instances details
KeyModifier ToUpper Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data LowerFirst Source #

Lower cases the first character, corresponds to toLower.

Since: 0.0.2.0

Instances

Instances details
KeyModifier LowerFirst Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data UpperFirst Source #

Upper cases the first character, corresponds to toUpper.

Since: 0.0.2.0

Instances

Instances details
KeyModifier UpperFirst Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data StripPrefix (prefix :: Symbol) Source #

Takes a type level string and removes that from the beginning of the text, corresponds to stripPrefix.

Since: 0.0.2.0

Instances

Instances details
KnownSymbol prefix => KeyModifier (StripPrefix prefix :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data StripSuffix (suffix :: Symbol) Source #

Takes a type level string and removes that from the end of the text, corresponds to 'Data.Text.stripSuffix.

Since: 0.0.2.0

Instances

Instances details
KnownSymbol prefix => KeyModifier (StripSuffix prefix :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

data CamelTo (separator :: Char) Source #

Takes a type level character known as the "separator" and will break the camel case string on its "humps" and then rejoin the string with the separator.

Since: 0.0.2.0

Instances

Instances details
KnownChar separator => KeyModifier (CamelTo separator :: Type) Source # 
Instance details

Defined in Cfg.Deriving.KeyModifier

type CamelToSnake = CamelTo '_' Source #

Specialized version of CamelTo where the separator is "_". Results in snake cased strings.

Since: 0.0.2.0

type CamelToKebab = CamelTo '-' Source #

Specialized version of CamelTo where the separator is "-". Results in kebab cased strings.

Since: 0.0.2.0

Helper Functions

mapFirst :: (Char -> Char) -> Text -> Maybe Text Source #

Map over the first character of a stream of Text

Since: 0.0.2.0

camelTo Source #

Arguments

:: Char

Separator character

-> String

Camel cased string

-> String 

Function for breaking a camel case string on its "humps" and re-joining on a provided separator char.

Since: 0.0.2.0

camelToText :: Char -> Text -> Text Source #

Data.Text.Text version of camelTo

Since: 0.0.2.0