kdl-hs-1.1.1: KDL language parser and API
Safe HaskellNone
LanguageGHC2021

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

Document

NodeList

data NodeList Source #

Constructors

NodeList 

Fields

data NodeListFormat Source #

Constructors

NodeListFormat 

Fields

  • leading :: Text

    Whitespace and comments preceding the first node.

  • trailing :: Text

    Whitespace and comments following the last node.

Instances

Instances details
Show NodeListFormat Source # 
Instance details

Defined in KDL.Types

Default NodeListFormat Source # 
Instance details

Defined in KDL.Types

Methods

def :: NodeListFormat #

Eq NodeListFormat Source # 
Instance details

Defined in KDL.Types

Helpers

filterNodes :: Text -> NodeList -> [Node] Source #

A helper to get all nodes with the given name

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

Expand
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

Expand
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

Expand
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

Expand
let
  config =
    """
    foo {
      - 1
      - 2
      - "test"
    }
    """
Right doc <- pure $ parse config
mapM getArg (getDashNodesAt "foo" doc) == Just [Number 1, Number 2, Text "test"]

Node

data Node Source #

Constructors

Node 

Instances

Instances details
Show Node Source # 
Instance details

Defined in KDL.Types

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

Eq Node Source # 
Instance details

Defined in KDL.Types

Methods

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

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

DecodeNode Node Source # 
Instance details

Defined in KDL.Decoder.Arrow

HasDecodeHistory Node Source # 
Instance details

Defined in KDL.Decoder.Internal.Decoder

Show (SchemaItem Node) Source # 
Instance details

Defined in KDL.Decoder.Schema

Eq (SchemaItem Node) Source # 
Instance details

Defined in KDL.Decoder.Schema

data SchemaItem Node Source # 
Instance details

Defined in KDL.Decoder.Schema

data DecodeHistory Node Source # 
Instance details

Defined in KDL.Decoder.Internal.Decoder

data NodeExtension Source #

Constructors

NodeExtension 

Instances

Instances details
Show NodeExtension Source # 
Instance details

Defined in KDL.Types

Default NodeExtension Source # 
Instance details

Defined in KDL.Types

Methods

def :: NodeExtension #

Eq NodeExtension Source # 
Instance details

Defined in KDL.Types

data NodeFormat Source #

Constructors

NodeFormat 

Fields

Instances

Instances details
Show NodeFormat Source # 
Instance details

Defined in KDL.Types

Default NodeFormat Source # 
Instance details

Defined in KDL.Types

Methods

def :: NodeFormat #

Eq NodeFormat Source # 
Instance details

Defined in KDL.Types

Helpers

getArgs :: Node -> [Value] Source #

Get all the positional arguments of the node.

getArg :: Node -> Maybe Value Source #

Get the first argument of the node.

getProps :: Node -> Map Text Value Source #

Get the properties of the node.

getProp :: Text -> Node -> Maybe Value Source #

Get the property with the given name in the node.

Entry

data Entry Source #

Constructors

Entry 

Fields

Instances

Instances details
Show Entry Source # 
Instance details

Defined in KDL.Types

Methods

showsPrec :: Int -> Entry -> ShowS #

show :: Entry -> String #

showList :: [Entry] -> ShowS #

Eq Entry Source # 
Instance details

Defined in KDL.Types

Methods

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

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

data EntryExtension Source #

Constructors

EntryExtension 

Instances

Instances details
Show EntryExtension Source # 
Instance details

Defined in KDL.Types

Default EntryExtension Source # 
Instance details

Defined in KDL.Types

Methods

def :: EntryExtension #

Eq EntryExtension Source # 
Instance details

Defined in KDL.Types

data EntryFormat Source #

Constructors

EntryFormat 

Fields

  • leading :: Text

    Whitespace and comments preceding the entry itself.

  • afterKey :: Text

    Whitespace and comments between an entry's key name and its equals sign.

  • afterEq :: Text

    Whitespace and comments between an entry's equals sign and its value.

  • trailing :: Text

    Whitespace and comments following the entry itself.

Instances

Instances details
Show EntryFormat Source # 
Instance details

Defined in KDL.Types

Default EntryFormat Source # 
Instance details

Defined in KDL.Types

Methods

def :: EntryFormat #

Eq EntryFormat Source # 
Instance details

Defined in KDL.Types

Value

data Value Source #

Constructors

Value 

Instances

Instances details
Show Value Source # 
Instance details

Defined in KDL.Types

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Eq Value Source # 
Instance details

Defined in KDL.Types

Methods

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

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

DecodeValue Value Source # 
Instance details

Defined in KDL.Decoder.Arrow

HasDecodeHistory Value Source # 
Instance details

Defined in KDL.Decoder.Internal.Decoder

Associated Types

data DecodeHistory Value 
Instance details

Defined in KDL.Decoder.Internal.Decoder

Bounded (SchemaItem Value) Source # 
Instance details

Defined in KDL.Decoder.Schema

Enum (SchemaItem Value) Source # 
Instance details

Defined in KDL.Decoder.Schema

Show (SchemaItem Value) Source # 
Instance details

Defined in KDL.Decoder.Schema

Eq (SchemaItem Value) Source # 
Instance details

Defined in KDL.Decoder.Schema

Ord (SchemaItem Value) Source # 
Instance details

Defined in KDL.Decoder.Schema

data SchemaItem Value Source # 
Instance details

Defined in KDL.Decoder.Schema

data DecodeHistory Value Source # 
Instance details

Defined in KDL.Decoder.Internal.Decoder

data ValueExtension Source #

Constructors

ValueExtension 

Instances

Instances details
Show ValueExtension Source # 
Instance details

Defined in KDL.Types

Default ValueExtension Source # 
Instance details

Defined in KDL.Types

Methods

def :: ValueExtension #

Eq ValueExtension Source # 
Instance details

Defined in KDL.Types

data ValueFormat Source #

Constructors

ValueFormat 

Fields

Instances

Instances details
Show ValueFormat Source # 
Instance details

Defined in KDL.Types

Default ValueFormat Source # 
Instance details

Defined in KDL.Types

Methods

def :: ValueFormat #

Eq ValueFormat Source # 
Instance details

Defined in KDL.Types

data ValueData Source #

Instances

Instances details
Show ValueData Source # 
Instance details

Defined in KDL.Types

Eq ValueData Source # 
Instance details

Defined in KDL.Types

DecodeValue ValueData Source # 
Instance details

Defined in KDL.Decoder.Arrow

Ann

data Ann Source #

Constructors

Ann 

Instances

Instances details
Show Ann Source # 
Instance details

Defined in KDL.Types

Methods

showsPrec :: Int -> Ann -> ShowS #

show :: Ann -> String #

showList :: [Ann] -> ShowS #

Eq Ann Source # 
Instance details

Defined in KDL.Types

Methods

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

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

data AnnExtension Source #

Constructors

AnnExtension 

Fields

Instances

Instances details
Show AnnExtension Source # 
Instance details

Defined in KDL.Types

Default AnnExtension Source # 
Instance details

Defined in KDL.Types

Methods

def :: AnnExtension #

Eq AnnExtension Source # 
Instance details

Defined in KDL.Types

data AnnFormat Source #

Constructors

AnnFormat 

Fields

  • leading :: Text

    Whitespace and comments preceding the annotation itself.

  • beforeId :: Text

    Whitespace and comments between the opening `(` and the identifier.

  • afterId :: Text

    Whitespace and comments between the identifier and the closing `)`.

  • trailing :: Text

    Whitespace and comments following the annotation itself.

Instances

Instances details
Show AnnFormat Source # 
Instance details

Defined in KDL.Types

Default AnnFormat Source # 
Instance details

Defined in KDL.Types

Methods

def :: AnnFormat #

Eq AnnFormat Source # 
Instance details

Defined in KDL.Types

Identifier

data Identifier Source #

Constructors

Identifier 

Instances

Instances details
Show Identifier Source # 
Instance details

Defined in KDL.Types

Eq Identifier Source # 
Instance details

Defined in KDL.Types

Ord Identifier Source # 
Instance details

Defined in KDL.Types

Span

data Span Source #

The span of a KDL element, if parsed with includeSpans. If includeSpans was not enabled, all fields are set to 0.

Constructors

Span 

Fields

Instances

Instances details
Show Span Source # 
Instance details

Defined in KDL.Types

Methods

showsPrec :: Int -> Span -> ShowS #

show :: Span -> String #

showList :: [Span] -> ShowS #

Default Span Source # 
Instance details

Defined in KDL.Types

Methods

def :: Span #

Eq Span Source # 
Instance details

Defined in KDL.Types

Methods

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

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

Ord Span Source # 
Instance details

Defined in KDL.Types

Methods

compare :: Span -> Span -> Ordering #

(<) :: Span -> Span -> Bool #

(<=) :: Span -> Span -> Bool #

(>) :: Span -> Span -> Bool #

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

max :: Span -> Span -> Span #

min :: Span -> Span -> Span #

Re-exports

def :: Default a => a #

The default value for this type.