config-value

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

https://github.com/glguy/config-value

Version on this page:0.8.3@rev:6
LTS Haskell 23.1:0.8.3@rev:8
Stackage Nightly 2024-12-26:0.8.3@rev:8
Latest on Hackage:0.8.3@rev:8

See all snapshots config-value appears in

MIT licensed by Eric Mertens
Maintained by [email protected]
This version can be pinned in stack with:config-value-0.8.3@sha256:3b9446be1a36aad5f8b71cd82bfe2d92ac33aae38a6823adc83a1e171ee29e50,1983

Module documentation for 0.8.3

Used by 1 package in nightly-2024-09-12(full list with versions):

config-value

Hackage Build Status

This package implements a simple, layout-based value definition language used for supplying configuration values to various applications.

Before starting to use config-value, you probably want to read the documentation for config-schema to see the user-friendly way to wrap this library.

Live Demo

The config-value and config-schema packages are available in a live demo.

Example

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

    inline-maps: {key1: value1, key2: value2}

    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

    floats:      [1e2, 0x3p-5, 24.48]
    underscores: 1_000_000

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)"

multiline: "haskell style\
           \string gaps"

Format

The language supports: Strings, Atoms, Integers, Lists, Nested Sections.

Sections are layout based. The contents of a section must be indented further than the section heading. The whitespace between a section heading and its colon is not significant. Section names must start with a letter and may contain letters, numbers, dashes (-), underscores (_), and periods (.).

Lists are either layout based with * prefixes or inline surrounded by [ and ] delimited by ,

Strings are surrounded by " and use Haskell-style escapes.

Numbers support decimal, hexadecimal (0x), octal (0o), and binary (0b).

Atoms follow the same lexical rule as section heading.

Changes

0.8.3

  • Add prettyInline for layout-free pretty-printing

0.8.2.1

  • Fix pretty-printing bug with long string literals

0.8.2

  • Add + and - to the set of layout-based list syntax bullets. All elements of the list are checked to see that a consistent bullet is used. Different bullets might be used to help make nested lists more understandable. - might be used to make things look more like YAML

0.8.1

0.8

  • Allow atoms and section names to start with @ or $
  • Add Config.Macro module

0.7.0.1

  • Fix pretty-printing of fractional, hexadecimal numbers

0.7.0.0

  • Updated number representation to preserve fractional part and added new Config.Number module with operations on this new type.

0.6.3.1

  • Build on GHC 8.4.1

0.6.3

  • Add valuePlate

0.6.2.1

  • Fixed error output for unexpected floating point literal

0.6.2

  • Nicer errors on unterminated inline lists and sections.
  • Stop enforcing well-formed text files

0.6.1

  • Add vim syntax highlighting file
  • Fix string gaps, they shouldn’t require a newline

0.6

  • Annotate Value with file positions
  • Derive Generic1 instances for Value

0.5.1

  • Allow trailing commas in lists and section lists
  • Support inline section lists using {}
  • Add more documentation

0.5

  • Add support for floating-point numbers

0.4.0.2

  • Internal lexer and parser improvements
  • Added support for \& escape sequence

0.4.0.1

  • Loosen version constraints to build back to GHC 7.4.2
  • Remove unused bytestring dependency

0.4

  • Make Atom a newtype to help distinguish it from Text
  • Add values traversal for traversing individual elements of a list

0.3

  • Replace yes and no with generalized atoms
  • Add character index to error position
  • Add human readable error messages

0.2

  • Take Text as the input to parse

0.1.1

  • Added Config.Lens module
  • Added aligned fields to pretty printer

0.1

  • Initial release