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.PrefixTree

Contents

- Non-empty prefix tree
- Prefix map that stores roots of `PrefixTree`

Description

Implementation of prefix tree for TOML AST.

Since: 0.0.0

Synopsis

- data PrefixTree a
  - = Leaf !Key !a
  - | Branch !Prefix !(Maybe a) !(PrefixMap a)
- singleT :: Key -> a -> PrefixTree a
- insertT :: Key -> a -> PrefixTree a -> PrefixTree a
- lookupT :: Key -> PrefixTree a -> Maybe a
- toListT :: PrefixTree a -> [(Key, a)]
- addPrefixT :: Prefix -> PrefixTree a -> PrefixTree a
- differenceWithT :: (a -> b -> Maybe a) -> PrefixTree a -> PrefixTree b -> Maybe (PrefixTree a)
- type PrefixMap a = HashMap Piece (PrefixTree a)
- single :: Key -> a -> PrefixMap a
- insert :: Key -> a -> PrefixMap a -> PrefixMap a
- lookup :: Key -> PrefixMap a -> Maybe a
- fromList :: [(Key, a)] -> PrefixMap a
- toList :: PrefixMap a -> [(Key, a)]
- differenceWith :: (a -> b -> Maybe a) -> PrefixMap a -> PrefixMap b -> PrefixMap a

# Non-empty prefix tree

data PrefixTree a #

Data structure to represent table tree for `toml`.

Since: 0.0.0

Constructors

Leaf | End of a key.
Fields !Key End piece of the key. !a Value at the end.
Branch | Values along pieces of a key.
Fields !Prefix Greatest common key prefix. !(Maybe a) Possible value at that point. !(PrefixMap a) Values at suffixes of the prefix.

#### Instances

Instances details

NFData a => NFData (PrefixTree a) # |
Instance details Defined in Toml.Type.PrefixTree Methods rnf :: PrefixTree a -> () #
Semigroup (PrefixTree a) # | Since: 0.3
Instance details Defined in Toml.Type.PrefixTree Methods (<>) :: PrefixTree a -> PrefixTree a -> PrefixTree a # sconcat :: NonEmpty (PrefixTree a) -> PrefixTree a # stimes :: Integral b => b -> PrefixTree a -> PrefixTree a #
Generic (PrefixTree a) # |
Instance details Defined in Toml.Type.PrefixTree Associated Types
type Rep (PrefixTree a) |
Instance details Defined in Toml.Type.PrefixTree type Rep (PrefixTree a) = D1 ('MetaData "PrefixTree" "Toml.Type.PrefixTree" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'False) (C1 ('MetaCons "Leaf" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Key) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Branch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Prefix) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PrefixMap a)))))
Methods from :: PrefixTree a -> Rep (PrefixTree a) x # to :: Rep (PrefixTree a) x -> PrefixTree a #
Show a => Show (PrefixTree a) # |
Instance details Defined in Toml.Type.PrefixTree Methods showsPrec :: Int -> PrefixTree a -> ShowS # show :: PrefixTree a -> String # showList :: [PrefixTree a] -> ShowS #
Eq a => Eq (PrefixTree a) # |
Instance details Defined in Toml.Type.PrefixTree Methods (==) :: PrefixTree a -> PrefixTree a -> Bool # (/=) :: PrefixTree a -> PrefixTree a -> Bool #
type Rep (PrefixTree a) # |
Instance details Defined in Toml.Type.PrefixTree type Rep (PrefixTree a) = D1 ('MetaData "PrefixTree" "Toml.Type.PrefixTree" "tomland-1.3.3.3-EUmut0o3bp2HnXO9U1VNsY" 'False) (C1 ('MetaCons "Leaf" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Key) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "Branch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Prefix) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (PrefixMap a)))))

singleT :: Key -> a -> PrefixTree a #

Creates a `PrefixTree` of one key-value element.

Since: 0.0.0

insertT :: Key -> a -> PrefixTree a -> PrefixTree a #

Inserts key-value element into the given `PrefixTree`.

Since: 0.0.0

lookupT :: Key -> PrefixTree a -> Maybe a #

Looks up the value at a key in the `PrefixTree`.

Since: 0.0.0

toListT :: PrefixTree a -> [(Key, a)] #

Converts `PrefixTree` to the list of pairs.

Since: 0.0.0

addPrefixT :: Prefix -> PrefixTree a -> PrefixTree a #

Push `Prefix` inside the given `PrefixTree`.

Since: 1.3.2.0

differenceWithT :: (a -> b -> Maybe a) -> PrefixTree a -> PrefixTree b -> Maybe (PrefixTree a) #

Difference of two `PrefixTree`s. Returns elements of the first `PrefixTree` that are not existing in the second one.

Since: 1.3.2.0

# Prefix map that stores roots of `PrefixTree`

type PrefixMap a = HashMap Piece (PrefixTree a) #

Map of layer names and corresponding `PrefixTree`s.

Since: 0.0.0

single :: Key -> a -> PrefixMap a #

Creates a `PrefixMap` of one key-value element.

Since: 0.0.0

insert :: Key -> a -> PrefixMap a -> PrefixMap a #

Inserts key-value element into the given `PrefixMap`.

Since: 0.0.0

lookup :: Key -> PrefixMap a -> Maybe a #

Looks up the value at a key in the `PrefixMap`.

Since: 0.0.0

fromList :: [(Key, a)] -> PrefixMap a #

Constructs `PrefixMap` structure from the given list of `Key` and value pairs.

Since: 0.0.0

toList :: PrefixMap a -> [(Key, a)] #

Converts `PrefixMap` to the list of pairs.

Since: 0.0.0

differenceWith :: (a -> b -> Maybe a) -> PrefixMap a -> PrefixMap b -> PrefixMap a #

Difference of two `PrefixMap`s. Returns elements of the first `PrefixMap` that are not existing in the second one.

Since: 1.3.2.0