config-value-0.4: 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"

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

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 
Atom Atom 
List [Value] 

newtype Atom Source

Wrapper to distinguish Atom from Text by type in a configuration.

Constructors

MkAtom 

Fields

atomName :: Text
 

parse Source

Arguments

:: Text

Source

-> Either String Value

Either ErrorMessage Result

Parse a configuration file and return the result on the right, or the position of an error on the left. Note: Text file lines are terminated by new-lines.

pretty :: Value -> 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.