config-value-0.8.3: Simple, layout-based value language similar to YAML or JSON

Copyright | (c) Eric Mertens 2017
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | Safe
Language | Haskell2010

Config

Contents

- Parsing
- Pretty-printing
- Types
- Numbers
- Errors

Description

This module parses files using the syntax demonstrated below. The full lexical syntax is available in the Alex source file. The full grammar is available in the Happy source file.

Configuration file schemas can be specified using the config-schema package. This package helps extract application-specific meaning from a `Value`, and can also generate documentation for the supported format.

The `config-value` format offers a simple, layout-based syntax for specifying configuration information. In addition configuration values can be pretty-printed back into valid concrete syntax.

# Example

    -- Line comments until newline
    layout:
      based:
        configuration:
          {} -- empty section

        sections:
         "glguy"

        {- Block comments
           {- nested comments -}
           "O'caml style {- strings in comments"
           so you can comment out otherwise valid
           portions of your config
        -}
        atoms      : yes

        decimal    : -1234
        hexadecimal: 0x1234
        octal      : 0o1234
        binary     : 0b1010

    lists:
       * sections: in-lists
         next-section: still-in-list
       * [ "inline", "lists" ]
       * * "nestable"
         * "layout"
         * "lists"
       * 3

    unicode : "standard Haskell format strings (1 ≤ 2)\x2228(2 ≤ 3)"

# Syntax

A configuration file should contain a single value at the top-level. Typically this value will be a list of sections (as seen in the example above).

Unicode character classes are fully supported. The alpha and digit character classes use the full Unicode range, rather than merely the ASCII ranges.

There are 5 distinct types of values possible in a configuration file:

- Sections list (list of key-value pairs)
- Lists
- Text
- Numbers
- Atoms

## Sections list

    KEY: VALUE
    KEY: VALUE
    KEY: VALUE

Sections lists are lists of key-value pairs. Each key in the list should start on the same column in the file. The value of the pair should be indented to the right of the key.

The lexical syntax for section names is identical to the lexical syntax of atoms. Section names are nonempty sequences starting with an alpha, `$` or `@` character followed by zero or more alpha, digit, period (.), underscore (_), or dash (-).

Section lists can be nested.

Section lists can be used inline, without layout, but surrounding them with `{` and `}` and separating the sections with `,`. The empty sections list is specified with `{}`.

Examples:

    key-1 : -- spaces are allowed between the section name and the colon
      key-1.1: value-1.1
      key-1.2: [ value-1.2 ]
    key-2: value-2
    key-3: {} -- the value for key-3 is the empty sections list
    key-4: { red: 1, blue: 2} -- inline syntax for sublist

## List

    * VALUE
    * VALUE
    * VALUE

Lists can be specified using either layout or inline syntax. There is no distinction between the two syntaxes in the abstract syntax.

Inline lists are surrounded by `[` and `]` with elements separated by `,`. The final list element may be terminated with a trailing comma.

Example: `[1, 2, 3]`

Layout list entries are started with a leading `*`, `+`, or `-`. Each leading bullet must occur in the some column of the file. Lists can be nested by starting the new list on a column to the right of the current list. A single list must use the same bullet token for every element of the list. Nested lists can choose a different bullet. This can help visually distinguish nested lists.

Layout based lists can not occur inside inline list syntax. Layout based section lists can occur inside layout based lists

Example:

    -- One list element containing an atom
    * item-1

    -- One list element containing a two element list
    * * item-2.1
      * item-2.2

    -- One list element containing two key-value pairs
    * key-1: value-1
      key-2: value-2

## Text

    "quoted string literals"

Text values are specified using the Haskell string literal syntax.

Text values are distinct from atoms described below. This allows a configuration file to make a distinction between the atom `default` and the text value `"default"`, for example.

For a detailed description of Haskell string literal syntax, see Haskell 2010 2.6 Character and String Literals

## Number

    123.456

Numbers can be written with integer and floating-point literals.

Prefix numbers with `-` to construct a negative number.

Integer literals support alternate base described below.

Floating-point literals can specify a power-of-10 exponent.

Bases

- No prefix for decimal (base 10) integer literals
- Prefix binary (base 2) integer literals with `0b` or `0B`
- Prefix octal (base 8) integer literals with `0o` or `0O`
- Prefix hexadecimal (base 16) integer literals with `0x` or `0X`. Upper and lower-cased hex digits are supported.

List of examples:

    [ 0, 42, -42, 123.45, 6E7, 1e+10, 3.4e-5, 0xfF, 0b101010, -0o77 ]

## Atom

    unquoted-string

Atoms are unquoted strings that are distinct from normal text values. This type is intended to represent enumerations in a configuration file.

Atoms are nonempty sequences starting with an alpha, `$`, or `@` character followed by zero or more alpha, digit, period (.), underscore (_), or dash (-).

Lexical syntax: `$alpha [$alpha $digit $unidigit \. _ \-]*`

List of examples:

    [ yes, no, default, MODE-61 ]

## Comments

Comments are valid white-space.

An ordinary comment begins with `--` and extends to the following newline.

    -- This is a comment

Use pairs of `{-` and `-}` to create comments that can span multiple lines. These comments can be nested.

    {- this {- is -}
           a comment -}

Synopsis

- parse :: Text -> Either ParseError (Value Position)
- data Position = Position {
  - posIndex :: !Int
  - posLine :: !Int
  - posColumn :: !Int
  }
- pretty :: Value a -> Doc
- prettyInline :: Value a -> Doc
- data Section a = Section {
  - sectionAnn :: a
  - sectionName :: Text
  - sectionValue :: Value a
  }
- data Value a
  - = Sections a [Section a]
  - | Number a Number
  - | Text a Text
  - | Atom a Atom
  - | List a [Value a]
- newtype Atom = MkAtom {
  - atomName :: Text
  }
- valueAnn :: Value a -> a
- data Number
- numberToInteger :: Number -> Maybe Integer
- numberToRational :: Number -> Rational
- integerToNumber :: Integer -> Number
- rationalToNumber :: Rational -> Number
- data ParseError = ParseError Position String

# Parsing

parse Source #

Arguments

:: Text | source text
-> Either ParseError (Value Position) | error message or parsed value

Parse a configuration file and return the result on the right, or the position of an error on the left.

The resulting value is annotated with source file locations.

Note: Text file lines are terminated by new-lines.

data Position Source #

A position in a text file

Constructors

Position |

Fields

- posIndex :: !Int
- posLine :: !Int
- posColumn :: !Int

#### Instances

Instances details

Read Position Source # |
Instance details Defined in Config.Tokens Methods readsPrec :: Int -> ReadS Position Source # readList :: ReadS [Position] Source # readPrec :: ReadPrec Position Source # readListPrec :: ReadPrec [Position] Source #
Show Position Source # |
Instance details Defined in Config.Tokens Methods showsPrec :: Int -> Position -> ShowS Source # show :: Position -> String Source # showList :: [Position] -> ShowS Source #
Eq Position Source # |
Instance details Defined in Config.Tokens Methods (==) :: Position -> Position -> Bool Source # (/=) :: Position -> Position -> Bool Source #
Ord Position Source # |
Instance details Defined in Config.Tokens Methods compare :: Position -> Position -> Ordering Source # (<) :: Position -> Position -> Bool Source # (<=) :: Position -> Position -> Bool Source # (>) :: Position -> Position -> Bool Source # (>=) :: Position -> Position -> Bool Source # max :: Position -> Position -> Position Source # min :: Position -> Position -> Position Source #

# Pretty-printing

pretty :: Value a -> Doc Source #

Pretty-print a `Value` as shown in the example. Sections will nest complex values underneath with indentation and simple values will be rendered on the same line as their section.

prettyInline :: Value a -> Doc Source #

Pretty-printer that uses no layout for sections or lists.

# Types

data Section a Source #

A single section of a `Value`

Example:

- `my-key: my-value` is ``Section` _ "my-key" (`Atom` _ "my-value")`

Constructors

Section |

Fields

- sectionAnn :: a
- sectionName :: Text
- sectionValue :: Value a

#### Instances

Instances details

Functor Section Source # |
Instance details Defined in Config.Value Methods fmap :: (a -> b) -> Section a -> Section b Source # (<$) :: a -> Section b -> Section a Source #
Foldable Section Source # |

Instance details

Defined in Config.Value

Methods

fold :: Monoid m => Section m -> m Source #

foldMap :: Monoid m => (a -> m) -> Section a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Section a -> m Source #

foldr :: (a -> b -> b) -> b -> Section a -> b Source #

foldr' :: (a -> b -> b) -> b -> Section a -> b Source #

foldl :: (b -> a -> b) -> b -> Section a -> b Source #

foldl' :: (b -> a -> b) -> b -> Section a -> b Source #

foldr1 :: (a -> a -> a) -> Section a -> a Source #

foldl1 :: (a -> a -> a) -> Section a -> a Source #

toList :: Section a -> [a] Source #

null :: Section a -> Bool Source #

length :: Section a -> Int Source #

elem :: Eq a => a -> Section a -> Bool Source #

maximum :: Ord a => Section a -> a Source #

minimum :: Ord a => Section a -> a Source #

sum :: Num a => Section a -> a Source #

product :: Num a => Section a -> a Source #

Traversable Section Source # |
Instance details Defined in Config.Value Methods traverse :: Applicative f => (a -> f b) -> Section a -> f (Section b) Source # sequenceA :: Applicative f => Section (f a) -> f (Section a) Source # mapM :: Monad m => (a -> m b) -> Section a -> m (Section b) Source # sequence :: Monad m => Section (m a) -> m (Section a) Source #
Generic1 Section Source # |

Instance details

Defined in Config.Value

Associated Types

type Rep1 Section |

Instance details

Defined in Config.Value

type Rep1 Section = D1 ('MetaData "Section" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "Section" 'PrefixI 'True) (S1 ('MetaSel ('Just "sectionAnn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: (S1 ('MetaSel ('Just "sectionName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "sectionValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Value))))

Methods

from1 :: Section a -> Rep1 Section a Source #

to1 :: Rep1 Section a -> Section a Source #

Data a => Data (Section a) Source # |

Instance details

Defined in Config.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Section a -> c (Section a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Section a) Source #

toConstr :: Section a -> Constr Source #

dataTypeOf :: Section a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Section a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Section a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Section a -> Section a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Section a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Section a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Section a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Section a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Section a -> m (Section a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Section a -> m (Section a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Section a -> m (Section a) Source #

Generic (Section a) Source # |

Instance details

Defined in Config.Value

Associated Types

type Rep (Section a) |

Instance details

Defined in Config.Value

type Rep (Section a) = D1 ('MetaData "Section" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "Section" 'PrefixI 'True) (S1 ('MetaSel ('Just "sectionAnn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Just "sectionName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "sectionValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Value a)))))

Methods

from :: Section a -> Rep (Section a) x Source #

to :: Rep (Section a) x -> Section a Source #

Read a => Read (Section a) Source # |
Instance details Defined in Config.Value Methods readsPrec :: Int -> ReadS (Section a) Source # readList :: ReadS [Section a] Source # readPrec :: ReadPrec (Section a) Source # readListPrec :: ReadPrec [Section a] Source #
Show a => Show (Section a) Source # |
Instance details Defined in Config.Value Methods showsPrec :: Int -> Section a -> ShowS Source # show :: Section a -> String Source # showList :: [Section a] -> ShowS Source #
Eq a => Eq (Section a) Source # |
Instance details Defined in Config.Value Methods (==) :: Section a -> Section a -> Bool Source # (/=) :: Section a -> Section a -> Bool Source #
type Rep1 Section Source # |

Instance details

Defined in Config.Value

type Rep1 Section = D1 ('MetaData "Section" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "Section" 'PrefixI 'True) (S1 ('MetaSel ('Just "sectionAnn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: (S1 ('MetaSel ('Just "sectionName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "sectionValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 Value))))

type Rep (Section a) Source # |

Instance details

Defined in Config.Value

type Rep (Section a) = D1 ('MetaData "Section" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "Section" 'PrefixI 'True) (S1 ('MetaSel ('Just "sectionAnn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: (S1 ('MetaSel ('Just "sectionName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "sectionValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Value a)))))

data Value a Source #

Sum type of the values supported by this language.

`Value` is parameterized over an annotation type indented to be used for file position or other application specific information. When no annotations are needed, `()` is a fine choice.

Constructors

Sections a [Section a] | lists of key-value pairs
Number a Number | numbers
Text a Text | quoted strings
Atom a Atom | unquoted strings
List a [Value a] | lists

#### Instances

Instances details

Functor Value Source # |
Instance details Defined in Config.Value Methods fmap :: (a -> b) -> Value a -> Value b Source # (<$) :: a -> Value b -> Value a Source #
Foldable Value Source # |

Instance details

Defined in Config.Value

Methods

fold :: Monoid m => Value m -> m Source #

foldMap :: Monoid m => (a -> m) -> Value a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Value a -> m Source #

foldr :: (a -> b -> b) -> b -> Value a -> b Source #

foldr' :: (a -> b -> b) -> b -> Value a -> b Source #

foldl :: (b -> a -> b) -> b -> Value a -> b Source #

foldl' :: (b -> a -> b) -> b -> Value a -> b Source #

foldr1 :: (a -> a -> a) -> Value a -> a Source #

foldl1 :: (a -> a -> a) -> Value a -> a Source #

toList :: Value a -> [a] Source #

null :: Value a -> Bool Source #

length :: Value a -> Int Source #

elem :: Eq a => a -> Value a -> Bool Source #

maximum :: Ord a => Value a -> a Source #

minimum :: Ord a => Value a -> a Source #

sum :: Num a => Value a -> a Source #

product :: Num a => Value a -> a Source #

Traversable Value Source # |
Instance details Defined in Config.Value Methods traverse :: Applicative f => (a -> f b) -> Value a -> f (Value b) Source # sequenceA :: Applicative f => Value (f a) -> f (Value a) Source # mapM :: Monad m => (a -> m b) -> Value a -> m (Value b) Source # sequence :: Monad m => Value (m a) -> m (Value a) Source #
Generic1 Value Source # |

Instance details

Defined in Config.Value

Associated Types

type Rep1 Value |

Instance details

Defined in Config.Value

type Rep1 Value = D1 ('MetaData "Value" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) ((C1 ('MetaCons "Sections" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) ([] :.: Rec1 Section)) :+: C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Number))) :+: (C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "Atom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Atom)) :+: C1 ('MetaCons "List" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) ([] :.: Rec1 Value)))))

Methods

from1 :: Value a -> Rep1 Value a Source #

to1 :: Rep1 Value a -> Value a Source #

Data a => Data (Value a) Source # |

Instance details

Defined in Config.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value a -> c (Value a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Value a) Source #

toConstr :: Value a -> Constr Source #

dataTypeOf :: Value a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Value a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Value a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Value a -> Value a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Value a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Value a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value a -> m (Value a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value a -> m (Value a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value a -> m (Value a) Source #

Generic (Value a) Source # |

Instance details

Defined in Config.Value

Associated Types

type Rep (Value a) |

Instance details

Defined in Config.Value

type Rep (Value a) = D1 ('MetaData "Value" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) ((C1 ('MetaCons "Sections" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Section a])) :+: C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Number))) :+: (C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "Atom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Atom)) :+: C1 ('MetaCons "List" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Value a])))))

Methods

from :: Value a -> Rep (Value a) x Source #

to :: Rep (Value a) x -> Value a Source #

Read a => Read (Value a) Source # |
Instance details Defined in Config.Value Methods readsPrec :: Int -> ReadS (Value a) Source # readList :: ReadS [Value a] Source # readPrec :: ReadPrec (Value a) Source # readListPrec :: ReadPrec [Value a] Source #
Show a => Show (Value a) Source # |
Instance details Defined in Config.Value Methods showsPrec :: Int -> Value a -> ShowS Source # show :: Value a -> String Source # showList :: [Value a] -> ShowS Source #
Eq a => Eq (Value a) Source # |
Instance details Defined in Config.Value Methods (==) :: Value a -> Value a -> Bool Source # (/=) :: Value a -> Value a -> Bool Source #
type Rep1 Value Source # |

Instance details

Defined in Config.Value

type Rep1 Value = D1 ('MetaData "Value" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) ((C1 ('MetaCons "Sections" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) ([] :.: Rec1 Section)) :+: C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Number))) :+: (C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "Atom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Atom)) :+: C1 ('MetaCons "List" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) ([] :.: Rec1 Value)))))

type Rep (Value a) Source # |

Instance details

Defined in Config.Value

type Rep (Value a) = D1 ('MetaData "Value" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) ((C1 ('MetaCons "Sections" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Section a])) :+: C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Number))) :+: (C1 ('MetaCons "Text" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "Atom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Atom)) :+: C1 ('MetaCons "List" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Value a])))))

newtype Atom Source #

Wrapper to distinguish `Atom` from `Text` by type in a configuration. Atoms can be constructed using the `OverloadedStrings` extension.

Constructors

MkAtom |

Fields

- atomName :: Text

#### Instances

Instances details

Data Atom Source # |

Instance details

Defined in Config.Value

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Atom -> c Atom Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Atom Source #

toConstr :: Atom -> Constr Source #

dataTypeOf :: Atom -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Atom) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Atom) Source #

gmapT :: (forall b. Data b => b -> b) -> Atom -> Atom Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Atom -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Atom -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Atom -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Atom -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Atom -> m Atom Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Atom -> m Atom Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Atom -> m Atom Source #

IsString Atom Source # |
Instance details Defined in Config.Value Methods fromString :: String -> Atom Source #
Generic Atom Source # |

Instance details

Defined in Config.Value

Associated Types

type Rep Atom |
Instance details Defined in Config.Value type Rep Atom = D1 ('MetaData "Atom" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'True) (C1 ('MetaCons "MkAtom" 'PrefixI 'True) (S1 ('MetaSel ('Just "atomName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Methods

from :: Atom -> Rep Atom x Source #

to :: Rep Atom x -> Atom Source #

Read Atom Source # |
Instance details Defined in Config.Value Methods readsPrec :: Int -> ReadS Atom Source # readList :: ReadS [Atom] Source # readPrec :: ReadPrec Atom Source # readListPrec :: ReadPrec [Atom] Source #
Show Atom Source # |
Instance details Defined in Config.Value Methods showsPrec :: Int -> Atom -> ShowS Source # show :: Atom -> String Source # showList :: [Atom] -> ShowS Source #
Eq Atom Source # |
Instance details Defined in Config.Value Methods (==) :: Atom -> Atom -> Bool Source # (/=) :: Atom -> Atom -> Bool Source #
Ord Atom Source # |
Instance details Defined in Config.Value Methods compare :: Atom -> Atom -> Ordering Source # (<) :: Atom -> Atom -> Bool Source # (<=) :: Atom -> Atom -> Bool Source # (>) :: Atom -> Atom -> Bool Source # (>=) :: Atom -> Atom -> Bool Source # max :: Atom -> Atom -> Atom Source # min :: Atom -> Atom -> Atom Source #
type Rep Atom Source # |
Instance details Defined in Config.Value type Rep Atom = D1 ('MetaData "Atom" "Config.Value" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'True) (C1 ('MetaCons "MkAtom" 'PrefixI 'True) (S1 ('MetaSel ('Just "atomName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

valueAnn :: Value a -> a Source #

Returns the annotation for a value.

# Numbers

data Number Source #

Numbers are represented as base, coefficient, and exponent.

The most convenient way to get numbers into and out of this form is to use one of: `numberToRational`, `numberToInteger`, `rationalToNumber`, or `integerToNumber`.

This representation is explicit about the radix and exponent used to facilitate better pretty-printing. By using explicit exponents extremely large numbers can be represented compactly. Consider that it is easy to write `1e100000000` which would use a significant amount of memory if realized as an `Integer`. This representation allows concerned programs to check bounds before converting to a representation like `Integer`.

#### Instances

Instances details

Data Number Source # |

Instance details

Defined in Config.Number

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Number -> c Number Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Number Source #

toConstr :: Number -> Constr Source #

dataTypeOf :: Number -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Number) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Number) Source #

gmapT :: (forall b. Data b => b -> b) -> Number -> Number Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Number -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Number -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Number -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Number -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Number -> m Number Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Number -> m Number Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Number -> m Number Source #

Generic Number Source # |

Instance details

Defined in Config.Number

Associated Types

type Rep Number |

Instance details

Defined in Config.Number

type Rep Number = D1 ('MetaData "Number" "Config.Number" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "MkNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "numberRadix") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Radix) :*: S1 ('MetaSel ('Just "numberCoefficient") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Rational)))

Methods

from :: Number -> Rep Number x Source #

to :: Rep Number x -> Number Source #

Read Number Source # |
Instance details Defined in Config.Number Methods readsPrec :: Int -> ReadS Number Source # readList :: ReadS [Number] Source # readPrec :: ReadPrec Number Source # readListPrec :: ReadPrec [Number] Source #
Show Number Source # |
Instance details Defined in Config.Number Methods showsPrec :: Int -> Number -> ShowS Source # show :: Number -> String Source # showList :: [Number] -> ShowS Source #
Eq Number Source # |
Instance details Defined in Config.Number Methods (==) :: Number -> Number -> Bool Source # (/=) :: Number -> Number -> Bool Source #
Ord Number Source # |
Instance details Defined in Config.Number Methods compare :: Number -> Number -> Ordering Source # (<) :: Number -> Number -> Bool Source # (<=) :: Number -> Number -> Bool Source # (>) :: Number -> Number -> Bool Source # (>=) :: Number -> Number -> Bool Source # max :: Number -> Number -> Number Source # min :: Number -> Number -> Number Source #
type Rep Number Source # |

Instance details

Defined in Config.Number

type Rep Number = D1 ('MetaData "Number" "Config.Number" "config-value-0.8.3-IpF6E1RCTYnALBsLrK00Yp" 'False) (C1 ('MetaCons "MkNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "numberRadix") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Radix) :*: S1 ('MetaSel ('Just "numberCoefficient") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Rational)))

numberToInteger :: Number -> Maybe Integer Source #

Convert a number to a `Integer`. Warning: This can use a lot of memory in the case of very large exponent parts.

numberToRational :: Number -> Rational Source #

Convert a number to a `Rational`. Warning: This can use a lot of memory in the case of very large exponent parts.

integerToNumber :: Integer -> Number Source #

`Integer` to a radix 10 `Number` with no exponent

rationalToNumber :: Rational -> Number Source #

`Rational` to a radix 10 `Number` with no exponent

# Errors

data ParseError Source #

Error messages that can occur during parsing annotated with a file position.

Constructors

ParseError Position String |

#### Instances

Instances details

Exception ParseError Source # | `displayException` implements a pretty format
Instance details Defined in Config Methods toException :: ParseError -> SomeException Source # fromException :: SomeException -> Maybe ParseError Source # displayException :: ParseError -> String Source # backtraceDesired :: ParseError -> Bool Source #
Read ParseError Source # |
Instance details Defined in Config Methods readsPrec :: Int -> ReadS ParseError Source # readList :: ReadS [ParseError] Source # readPrec :: ReadPrec ParseError Source # readListPrec :: ReadPrec [ParseError] Source #
Show ParseError Source # |
Instance details Defined in Config Methods showsPrec :: Int -> ParseError -> ShowS Source # show :: ParseError -> String Source # showList :: [ParseError] -> ShowS Source #
Eq ParseError Source # |
Instance details Defined in Config Methods (==) :: ParseError -> ParseError -> Bool Source # (/=) :: ParseError -> ParseError -> Bool Source #
Ord ParseError Source # |

Instance details

Defined in Config

Methods

compare :: ParseError -> ParseError -> Ordering Source #

(<) :: ParseError -> ParseError -> Bool Source #

(<=) :: ParseError -> ParseError -> Bool Source #

(>) :: ParseError -> ParseError -> Bool Source #

(>=) :: ParseError -> ParseError -> Bool Source #

max :: ParseError -> ParseError -> ParseError Source #

min :: ParseError -> ParseError -> ParseError Source #