tomland-1.3.3.3: Bidirectional TOML serialization

Copyright | (c) 2018-2022 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Stability | Stable
Portability | Portable
Safe Haskell | None
Language | Haskell2010

Toml.Type.Key

Contents

- Core types
- Key difference

Description

Implementation of key type. The type is used for key-value pairs and table names.

Since: 1.3.0.0

Synopsis

- newtype Key = Key {
  - unKey :: NonEmpty Piece
  }
- type Prefix = Key
- newtype Piece = Piece {
  - unPiece :: Text
  }
- pattern (:||) :: Piece -> [Piece] -> Key
- (<|) :: Piece -> Key -> Key
- data KeysDiff
  - = Equal
  - | NoPrefix
  - | FstIsPref !Key
  - | SndIsPref !Key
  - | Diff !Key !Key !Key
- keysDiff :: Key -> Key -> KeysDiff

# Core types

newtype Key #

Key of value in `key = val` pair. Represents as non-empty list of key components — `Piece`s. Key like

    site."google.com"

is represented like

    Key (Piece "site" :| [Piece "\"google.com\""])

Since: 0.0.0

Constructors

Key |
Fields unKey :: NonEmpty Piece

#### Instances

Instances details

NFData Key # |
Instance details Defined in Toml.Type.Key Methods rnf :: Key -> () #
Semigroup Key # |
Instance details Defined in Toml.Type.Key Methods (<>) :: Key -> Key -> Key # sconcat :: NonEmpty Key -> Key # stimes :: Integral b => b -> Key -> Key #
IsString Key # | Split a dot-separated string into `Key`. Empty string turns into a `Key` with single element — empty `Piece`. This instance is not safe for now. Use carefully. If you try to use as a key string like this `site."google.com"` you will have list of three components instead of desired two. Since: 0.1.0
Instance details Defined in Toml.Type.Key Methods fromString :: String -> Key #
Generic Key # |
Instance details Defined in Toml.Type.Key Associated Types
type Rep Key |
Instance details Defined in Toml.Type.Key type Rep Key = D1 ('MetaData "Key" "Toml.Type.Key" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'True) (C1 ('MetaCons "Key" 'PrefixI 'True) (S1 ('MetaSel ('Just "unKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Piece))))
Methods from :: Key -> Rep Key x # to :: Rep Key x -> Key #
Show Key # |
Instance details Defined in Toml.Type.Key Methods showsPrec :: Int -> Key -> ShowS # show :: Key -> String # showList :: [Key] -> ShowS #
Eq Key # |
Instance details Defined in Toml.Type.Key Methods (==) :: Key -> Key -> Bool # (/=) :: Key -> Key -> Bool #
Ord Key # |
Instance details Defined in Toml.Type.Key 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 #
Hashable Key # |
Instance details Defined in Toml.Type.Key Methods hashWithSalt :: Int -> Key -> Int # hash :: Key -> Int #
type Rep Key # |
Instance details Defined in Toml.Type.Key type Rep Key = D1 ('MetaData "Key" "Toml.Type.Key" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'True) (C1 ('MetaCons "Key" 'PrefixI 'True) (S1 ('MetaSel ('Just "unKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty Piece))))

type Prefix = Key #

Type synonym for `Key`.

Since: 0.0.0

newtype Piece #

Represents the key piece of some layer.

Since: 0.0.0

Constructors

Piece |
Fields unPiece :: Text

#### Instances

Instances details

NFData Piece # |
Instance details Defined in Toml.Type.Key Methods rnf :: Piece -> () #
IsString Piece # |
Instance details Defined in Toml.Type.Key Methods fromString :: String -> Piece #
Generic Piece # |
Instance details Defined in Toml.Type.Key Associated Types
type Rep Piece |
Instance details Defined in Toml.Type.Key type Rep Piece = D1 ('MetaData "Piece" "Toml.Type.Key" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'True) (C1 ('MetaCons "Piece" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPiece") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Methods from :: Piece -> Rep Piece x # to :: Rep Piece x -> Piece #
Show Piece # |
Instance details Defined in Toml.Type.Key Methods showsPrec :: Int -> Piece -> ShowS # show :: Piece -> String # showList :: [Piece] -> ShowS #
Eq Piece # |
Instance details Defined in Toml.Type.Key Methods (==) :: Piece -> Piece -> Bool # (/=) :: Piece -> Piece -> Bool #
Ord Piece # |
Instance details Defined in Toml.Type.Key Methods compare :: Piece -> Piece -> Ordering # (<) :: Piece -> Piece -> Bool # (<=) :: Piece -> Piece -> Bool # (>) :: Piece -> Piece -> Bool # (>=) :: Piece -> Piece -> Bool # max :: Piece -> Piece -> Piece # min :: Piece -> Piece -> Piece #
Hashable Piece # |
Instance details Defined in Toml.Type.Key Methods hashWithSalt :: Int -> Piece -> Int # hash :: Piece -> Int #
type Rep Piece # |
Instance details Defined in Toml.Type.Key type Rep Piece = D1 ('MetaData "Piece" "Toml.Type.Key" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'True) (C1 ('MetaCons "Piece" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPiece") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

pattern (:||) :: Piece -> [Piece] -> Key #

Bidirectional pattern synonym for constructing and deconstructing `Key`s.

(<|) :: Piece -> Key -> Key #

Prepends `Piece` to the beginning of the `Key`.

# Key difference

data KeysDiff #

Data represent difference between two keys.

Since: 0.0.0

Constructors

Equal | Keys are equal
NoPrefix | Keys don't have any common part.
FstIsPref | The first key is the prefix of the second one.
Fields !Key Rest of the second key.
SndIsPref | The second key is the prefix of the first one.
Fields !Key Rest of the first key.
Diff | Key have a common prefix.
Fields !Key Common prefix. !Key Rest of the first key. !Key Rest of the second key.

#### Instances

Instances details

Show KeysDiff # |
Instance details Defined in Toml.Type.Key Methods showsPrec :: Int -> KeysDiff -> ShowS # show :: KeysDiff -> String # showList :: [KeysDiff] -> ShowS #
Eq KeysDiff # |
Instance details Defined in Toml.Type.Key Methods (==) :: KeysDiff -> KeysDiff -> Bool # (/=) :: KeysDiff -> KeysDiff -> Bool #

keysDiff :: Key -> Key -> KeysDiff #

Find key difference between two keys.

Since: 0.0.0