Nyarna: A structured data authoring language

Designed as Evolution of LaTeX

Nyarna's syntax and feature set was primarily inspired by LaTeX. The initial idea was to have a language viable to be used as frontend for LaTeX – Nyarna isn't quite there yet – while being more user-friendly and flexible. Besides LaTeX, Nyarna also takes ideas from XSLT, YAML, Nim and Zig.

Structured Input, Flexible Output

Nyarna understands complex structures and provides a static type system for modelling structured data. Data input is decoupled from processing. You can write processors that generate HTML, PDF or other outputs from the same input data.

Extensible Schemas

You tell Nyarna about the structure of your data with a Schema. Schemas are written in Nyarna and can contain Backends that define how the data can be processed. Other users can write Extensions that build upon your Schema, inject additional input structures, and extend the backends to accommodate for the additions. The ability to inject Extensions makes Nyarna's Schemas modular and flexible.

Parameters and Templating

A document can define parameters whose values must be given by the caller. This makes Nyarna a type-safe templating system.

First-Class Types and Embeddability

Types are first-class values, as are Schemas. The ability to inspect types at runtime potentially allows you to autogenerate code from a schema. With this, you could embed Nyarna in your application and deserialize input into native types.

Power Tool with Complexity Layers

While Nyarna provides a lot of features, it is not necessary to know about them all to use the language. Simple use-cases, like text templating, require only minimal syntax. Writing content for a given schema still doesn't require the more complex features. You will probably not need to know much about the type system before you start writing functions. The most complex features are usually only needed for writing Schemas.

Available in your Browser

Nyarna is nowhere near stable yet, but the implementation is good enough to demonstrate its features. Check out the tour to try it out!

#!/usr/bin/env nyarna --
# with a shebang, this is directly executable.

# This document can be processed standalone.
  # takes a single argument of type Text
  who: \Text

# output text, refer to the argument
Hello, \who!

# declare your own types and functions
  Bus = \Record:
    fits: \Natural
    name: \Text

  Buses = \List(\Bus)

  busFor = \func:
    num: \Natural
    \Bus(fits=\num, name=Bus for \num persons)

# have variables
  smallBus = \busFor(10)
  largeBus = \busFor(42)

# do loops
\for(\Buses(\smallBus, \largeBus), collector=\Concat):|\b|
  The \b::name fits \b::fits persons.\