Haga is a strict, cardinality-enforcing configuration language, inspired by CUE.
It is designed to eliminate ambiguity in system definitions.
Unlike standard configuration formats (JSON, TOML, YAML) which only define structure, Haga forces the author to explicitly declare the necessity and cardinality of every resource.
Haga statements follow a strict [Modal] [Noun] [Arguments] structure.
must: Singleton. Exactly one must exist. (1)- Error if missing. Error if duplicated.
may: Option. Zero or one may exist. (0..1)- No error if missing. Error if duplicated.
any: Collection. Zero or more may exist. (0..N)- No error if missing. No error if duplicated.
some: Requirement. One or more must exist. (1..N)- Error if missing. No error if duplicated.
For user convenience, but not implementation, the grammar is also a trivial subset of Ruby's.
Resources are namespaces within scopes to prevent collisions and organize intent.
scope networking {
# We MUST have a primary interface in this scenario.
must primary_interface "eth0"
# We MAY have a debug interface, but only one.
may interface "usb0"
# We can have ANY number of firewall rules.
any allow "eth0", "tcp", 22
any deny "eth0", "udp", 53
}Haga is currently used as the configuration language for the Kozane Linux "architecture".
A standalone Zig library and toolkit for Haga is under development.
The complete syntax of Haga is defined by this ABNF grammar. It is entirely context-free and recursive.
If you know of a shorter ABNF definition for a config file other than JSON, please drop me a note.