| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
KDL.Types
Description
Defines the types that make up a KDL document.
This module enables -XNoFieldSelectors, so none of the fields create implicit
selector functions. Instead, use -XOverloadedRecordDot,
-XNamedFieldPuns/-XRecordWildCards, or explicitly pattern-match.
Synopsis
- type Document = NodeList
- data NodeList = NodeList {
- nodes :: [Node]
- ext :: NodeListExtension
- data NodeListExtension = NodeListExtension {
- format :: Maybe NodeListFormat
- span :: Span
- data NodeListFormat = NodeListFormat {}
- filterNodes :: Text -> NodeList -> [Node]
- lookupNode :: Text -> NodeList -> Maybe Node
- getArgAt :: Text -> NodeList -> Maybe Value
- getArgsAt :: Text -> NodeList -> [Value]
- getDashChildrenAt :: Text -> NodeList -> [Value]
- getDashNodesAt :: Text -> NodeList -> [Node]
- data Node = Node {}
- data NodeExtension = NodeExtension {
- format :: Maybe NodeFormat
- span :: Span
- data NodeFormat = NodeFormat {
- leading :: Text
- beforeChildren :: Text
- beforeTerminator :: Text
- terminator :: Text
- trailing :: Text
- getArgs :: Node -> [Value]
- getArg :: Node -> Maybe Value
- getProps :: Node -> Map Text Value
- getProp :: Text -> Node -> Maybe Value
- data Entry = Entry {
- name :: Maybe Identifier
- value :: Value
- ext :: EntryExtension
- data EntryExtension = EntryExtension {
- format :: Maybe EntryFormat
- span :: Span
- data EntryFormat = EntryFormat {}
- data Value = Value {}
- data ValueExtension = ValueExtension {
- format :: Maybe ValueFormat
- span :: Span
- data ValueFormat = ValueFormat {}
- data ValueData
- data Ann = Ann {}
- data AnnExtension = AnnExtension {}
- data AnnFormat = AnnFormat {}
- data Identifier = Identifier {
- value :: Text
- ext :: IdentifierExtension
- data IdentifierExtension = IdentifierExtension {
- format :: Maybe IdentifierFormat
- span :: Span
- data IdentifierFormat = IdentifierFormat {}
- fromIdentifier :: Identifier -> Text
- toIdentifier :: Text -> Identifier
- data Span = Span {}
- def :: Default a => a
Document
NodeList
Constructors
| NodeList | |
Fields
| |
Instances
| Show NodeList Source # | |||||
| Eq NodeList Source # | |||||
| HasDecodeHistory NodeList Source # | |||||
Defined in KDL.Decoder.Internal.Decoder Associated Types
Methods | |||||
| Show (SchemaItem NodeList) Source # | |||||
Defined in KDL.Decoder.Schema | |||||
| Eq (SchemaItem NodeList) Source # | |||||
Defined in KDL.Decoder.Schema Methods (==) :: SchemaItem NodeList -> SchemaItem NodeList -> Bool # (/=) :: SchemaItem NodeList -> SchemaItem NodeList -> Bool # | |||||
| data SchemaItem NodeList Source # | |||||
Defined in KDL.Decoder.Schema | |||||
| data DecodeHistory NodeList Source # | |||||
Defined in KDL.Decoder.Internal.Decoder | |||||
data NodeListExtension Source #
Constructors
| NodeListExtension | |
Fields
| |
Instances
| Show NodeListExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> NodeListExtension -> ShowS # show :: NodeListExtension -> String # showList :: [NodeListExtension] -> ShowS # | |
| Default NodeListExtension Source # | |
Defined in KDL.Types Methods | |
| Eq NodeListExtension Source # | |
Defined in KDL.Types Methods (==) :: NodeListExtension -> NodeListExtension -> Bool # (/=) :: NodeListExtension -> NodeListExtension -> Bool # | |
data NodeListFormat Source #
Constructors
| NodeListFormat | |
Instances
| Show NodeListFormat Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> NodeListFormat -> ShowS # show :: NodeListFormat -> String # showList :: [NodeListFormat] -> ShowS # | |
| Default NodeListFormat Source # | |
Defined in KDL.Types Methods def :: NodeListFormat # | |
| Eq NodeListFormat Source # | |
Defined in KDL.Types Methods (==) :: NodeListFormat -> NodeListFormat -> Bool # (/=) :: NodeListFormat -> NodeListFormat -> Bool # | |
Helpers
lookupNode :: Text -> NodeList -> Maybe Node Source #
A helper to get the first node with the given name
getArgAt :: Text -> NodeList -> Maybe Value Source #
A helper to get the first argument of the first node with the given name. A utility for nodes that are acting like a key-value store.
Example
let
config =
"""
foo 1
"""
Right doc <- pure $ parse config
getArgAt "foo" doc == Just (Number 1)
getArgsAt :: Text -> NodeList -> [Value] Source #
A helper to get all the arguments of the first node with the given name. A utility for nodes that are acting like a key-value store with a list of values.
Example
let
config =
"""
foo 1 2 "test"
"""
Right doc <- pure $ parse config
getArgsAt "foo" doc == [Number 1, Number 2, Text "test"]
getDashChildrenAt :: Text -> NodeList -> [Value] Source #
A helper for getting child values following the KDL convention of being named "-".
Example
let
config =
"""
foo {
- 1
- 2
- "test"
}
"""
Right doc <- pure $ parse config
getDashChildrenAt "foo" doc == [Number 1, Number 2, Text "test"]
getDashNodesAt :: Text -> NodeList -> [Node] Source #
A helper for getting child nodes following the KDL convention of being named "-".
Example
let
config =
"""
foo {
- 1
- 2
- "test"
}
"""
Right doc <- pure $ parse config
mapM getArg (getDashNodesAt "foo" doc) == Just [Number 1, Number 2, Text "test"]
Node
Constructors
| Node | |
Instances
| Show Node Source # | |||||
| Eq Node Source # | |||||
| DecodeNode Node Source # | |||||
Defined in KDL.Decoder.Arrow | |||||
| HasDecodeHistory Node Source # | |||||
Defined in KDL.Decoder.Internal.Decoder Associated Types
Methods | |||||
| Show (SchemaItem Node) Source # | |||||
Defined in KDL.Decoder.Schema | |||||
| Eq (SchemaItem Node) Source # | |||||
Defined in KDL.Decoder.Schema Methods (==) :: SchemaItem Node -> SchemaItem Node -> Bool # (/=) :: SchemaItem Node -> SchemaItem Node -> Bool # | |||||
| data SchemaItem Node Source # | |||||
| data DecodeHistory Node Source # | |||||
Defined in KDL.Decoder.Internal.Decoder | |||||
data NodeExtension Source #
Constructors
| NodeExtension | |
Fields
| |
Instances
| Show NodeExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> NodeExtension -> ShowS # show :: NodeExtension -> String # showList :: [NodeExtension] -> ShowS # | |
| Default NodeExtension Source # | |
Defined in KDL.Types Methods def :: NodeExtension # | |
| Eq NodeExtension Source # | |
Defined in KDL.Types Methods (==) :: NodeExtension -> NodeExtension -> Bool # (/=) :: NodeExtension -> NodeExtension -> Bool # | |
data NodeFormat Source #
Constructors
| NodeFormat | |
Fields
| |
Instances
| Show NodeFormat Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> NodeFormat -> ShowS # show :: NodeFormat -> String # showList :: [NodeFormat] -> ShowS # | |
| Default NodeFormat Source # | |
Defined in KDL.Types Methods def :: NodeFormat # | |
| Eq NodeFormat Source # | |
Defined in KDL.Types | |
Helpers
Entry
Constructors
| Entry | |
Fields
| |
data EntryExtension Source #
Constructors
| EntryExtension | |
Fields
| |
Instances
| Show EntryExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> EntryExtension -> ShowS # show :: EntryExtension -> String # showList :: [EntryExtension] -> ShowS # | |
| Default EntryExtension Source # | |
Defined in KDL.Types Methods def :: EntryExtension # | |
| Eq EntryExtension Source # | |
Defined in KDL.Types Methods (==) :: EntryExtension -> EntryExtension -> Bool # (/=) :: EntryExtension -> EntryExtension -> Bool # | |
data EntryFormat Source #
Constructors
| EntryFormat | |
Fields
| |
Instances
| Show EntryFormat Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> EntryFormat -> ShowS # show :: EntryFormat -> String # showList :: [EntryFormat] -> ShowS # | |
| Default EntryFormat Source # | |
Defined in KDL.Types Methods def :: EntryFormat # | |
| Eq EntryFormat Source # | |
Defined in KDL.Types | |
Value
Instances
data ValueExtension Source #
Constructors
| ValueExtension | |
Fields
| |
Instances
| Show ValueExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> ValueExtension -> ShowS # show :: ValueExtension -> String # showList :: [ValueExtension] -> ShowS # | |
| Default ValueExtension Source # | |
Defined in KDL.Types Methods def :: ValueExtension # | |
| Eq ValueExtension Source # | |
Defined in KDL.Types Methods (==) :: ValueExtension -> ValueExtension -> Bool # (/=) :: ValueExtension -> ValueExtension -> Bool # | |
data ValueFormat Source #
Constructors
| ValueFormat | |
Instances
| Show ValueFormat Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> ValueFormat -> ShowS # show :: ValueFormat -> String # showList :: [ValueFormat] -> ShowS # | |
| Default ValueFormat Source # | |
Defined in KDL.Types Methods def :: ValueFormat # | |
| Eq ValueFormat Source # | |
Defined in KDL.Types | |
Ann
Constructors
| Ann | |
Fields
| |
data AnnExtension Source #
Instances
| Show AnnExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> AnnExtension -> ShowS # show :: AnnExtension -> String # showList :: [AnnExtension] -> ShowS # | |
| Default AnnExtension Source # | |
Defined in KDL.Types Methods def :: AnnExtension # | |
| Eq AnnExtension Source # | |
Defined in KDL.Types | |
Constructors
| AnnFormat | |
Fields
| |
Identifier
data Identifier Source #
Constructors
| Identifier | |
Fields
| |
Instances
| Show Identifier Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> Identifier -> ShowS # show :: Identifier -> String # showList :: [Identifier] -> ShowS # | |
| Eq Identifier Source # | |
Defined in KDL.Types | |
| Ord Identifier Source # | |
Defined in KDL.Types Methods compare :: Identifier -> Identifier -> Ordering # (<) :: Identifier -> Identifier -> Bool # (<=) :: Identifier -> Identifier -> Bool # (>) :: Identifier -> Identifier -> Bool # (>=) :: Identifier -> Identifier -> Bool # max :: Identifier -> Identifier -> Identifier # min :: Identifier -> Identifier -> Identifier # | |
data IdentifierExtension Source #
Constructors
| IdentifierExtension | |
Fields
| |
Instances
| Show IdentifierExtension Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> IdentifierExtension -> ShowS # show :: IdentifierExtension -> String # showList :: [IdentifierExtension] -> ShowS # | |
| Default IdentifierExtension Source # | |
Defined in KDL.Types Methods | |
| Eq IdentifierExtension Source # | |
Defined in KDL.Types Methods (==) :: IdentifierExtension -> IdentifierExtension -> Bool # (/=) :: IdentifierExtension -> IdentifierExtension -> Bool # | |
| Ord IdentifierExtension Source # | |
Defined in KDL.Types Methods compare :: IdentifierExtension -> IdentifierExtension -> Ordering # (<) :: IdentifierExtension -> IdentifierExtension -> Bool # (<=) :: IdentifierExtension -> IdentifierExtension -> Bool # (>) :: IdentifierExtension -> IdentifierExtension -> Bool # (>=) :: IdentifierExtension -> IdentifierExtension -> Bool # max :: IdentifierExtension -> IdentifierExtension -> IdentifierExtension # min :: IdentifierExtension -> IdentifierExtension -> IdentifierExtension # | |
data IdentifierFormat Source #
Constructors
| IdentifierFormat | |
Instances
| Show IdentifierFormat Source # | |
Defined in KDL.Types Methods showsPrec :: Int -> IdentifierFormat -> ShowS # show :: IdentifierFormat -> String # showList :: [IdentifierFormat] -> ShowS # | |
| Default IdentifierFormat Source # | |
Defined in KDL.Types Methods def :: IdentifierFormat # | |
| Eq IdentifierFormat Source # | |
Defined in KDL.Types Methods (==) :: IdentifierFormat -> IdentifierFormat -> Bool # (/=) :: IdentifierFormat -> IdentifierFormat -> Bool # | |
| Ord IdentifierFormat Source # | |
Defined in KDL.Types Methods compare :: IdentifierFormat -> IdentifierFormat -> Ordering # (<) :: IdentifierFormat -> IdentifierFormat -> Bool # (<=) :: IdentifierFormat -> IdentifierFormat -> Bool # (>) :: IdentifierFormat -> IdentifierFormat -> Bool # (>=) :: IdentifierFormat -> IdentifierFormat -> Bool # max :: IdentifierFormat -> IdentifierFormat -> IdentifierFormat # min :: IdentifierFormat -> IdentifierFormat -> IdentifierFormat # | |
fromIdentifier :: Identifier -> Text Source #
toIdentifier :: Text -> Identifier Source #
Span
The span of a KDL element, if parsed with includeSpans. If includeSpans
was not enabled, all fields are set to 0.