config-value
Simple, layout-based value language similar to YAML or JSON
https://github.com/glguy/config-value
LTS Haskell 22.41: | 0.8.3@rev:8 |
Stackage Nightly 2024-11-12: | 0.8.3@rev:8 |
Latest on Hackage: | 0.8.3@rev:8 |
config-value-0.8.3@sha256:595c008701fe50b6f97eb4ec50a5a2255648d2263dea7d68f1451e7f0e4bd2e9,1982
Module documentation for 0.8.3
config-value
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
-
Allow underscores in number literals Copied from https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0076-numeric-underscores.rst#new-syntax-this-proposal
Underscores are allowed and ignored
- in the middle of integer-parts of the literal syntax
- between base-markers (0x, 0o, 0b) and number part
- before the
eEpP
part of an exponent
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 forValue
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 fromText
- Add
values
traversal for traversing individual elements of a list
0.3
- Replace
yes
andno
with generalized atoms - Add character index to error position
- Add human readable error messages
0.2
- Take
Text
as the input toparse
0.1.1
- Added
Config.Lens
module - Added aligned fields to pretty printer
0.1
- Initial release