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

Safe HaskellSafe
LanguageHaskell2010

Config

Description

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

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

    sections:
     "glguy"

    booleans   : yes
    complicated: no

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

lists:
   * 1
   * [ "inline", "lists" ]
   * * "nestable"
     * "layout"
     * "lists"
   * 3

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

Synopsis

Documentation

data Section Source

A single section of a Value

Constructors

Section 

data Value Source

Sum type of the values supported by this language.

Constructors

Sections [Section] 
Number Int Integer

base number

Text Text 
Bool Bool 
List [Value] 

parse Source

Arguments

:: ByteString

UTF-8 encoded source

-> Either (Int, Int) Value

Either (Line,Column) Result

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

pretty :: Value -> Doc Source

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