Copyright | (c) 2019 Lucas David Traverso |
---|---|
License | MPL-2.0 |
Maintainer | Lucas David Traverso <lucas6246@gmail.com> |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Internal module for Key related features
Documentation
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.
mkKey :: String -> Key Source #
Helper function to create Key
s, this function always works, but
since Key
s reject some string this function transforms the input
to provide lawful Key
s 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' ".." == ""
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
rawKeyComponents :: Key -> [Text] Source #
Get raw components from a key, usually to do some manipulation