conferer-1.0.0.0: Configuration management library
Copyright(c) 2019 Lucas David Traverso
LicenseMPL-2.0
MaintainerLucas David Traverso <lucas6246@gmail.com>
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Conferer.Key.Internal

Description

Internal module for Key related features

Synopsis

Documentation

newtype Key Source #

This type is used extensivelly as a way to point into a Source and in turn into a Config. The intended way to create them is is using mkKey.

It's a list of alphanumeric words and each Source can interpret it as it sees fit.

Constructors

Key 

Fields

Instances

Instances details
Eq Key Source # 
Instance details

Defined in Conferer.Key.Internal

Methods

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

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

Ord Key Source # 
Instance details

Defined in Conferer.Key.Internal

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.Key.Internal

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

IsString Key Source # 
Instance details

Defined in Conferer.Key.Internal

Methods

fromString :: String -> Key #

mkKey :: String -> Key Source #

Helper function to create Keys, this function always works, but since Keys reject some string this function transforms the input to provide lawful Keys instead of throwing.

For example:

'mkKey' "sOmE.KEy" == "some.key"
'mkKey' "1.key" == "1.key"
'mkKey' "1_thing.key" == "1thing.key"
'mkKey' "some....key" == "some.key"
'mkKey' ".." == ""

fromText :: Text -> Key Source #

Same as mkKey but for Text

keyName :: Key -> Text Source #

Collapse a key into a textual representation

isKeyPrefixOf :: Key -> Key -> Bool Source #

This function tells if a key is a subkey of another key based using key fragments instead of letters as units

'isKeyPrefixOf' "foo" "foo.bar" == True
'isKeyPrefixOf' "foo" "foo" == True
'isKeyPrefixOf' "foo" "fooa" == False

stripKeyPrefix :: Key -> Key -> Maybe Key Source #

Given k1 and k2 this function drops k1 as a prefix from k2, if k1 is not a prefix of k2 it returns Nothing

'keyPrefixOf' "foo" "foo.bar" == Just "bar"
'keyPrefixOf' "foo" "foo" == Just ""
'keyPrefixOf' "foo" "fooa" == Nothing
'keyPrefixOf' "" k == Just k

(/.) :: Key -> Key -> Key Source #

Concatenate two keys

rawKeyComponents :: Key -> [Text] Source #

Get raw components from a key, usually to do some manipulation

unconsKey :: Key -> Maybe (Text, Key) Source #

Get first component of a key and the rest of the key