Skip to content
DominicBurkartPublic

About

Marigold is a programming language for operating on async streams that compiles to Rust πŸ΅οΈπŸ¦€

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

881 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Marigold

crates.io docs.rs website lines of code contributors bench codecov tests style wasm last commit

Marigold is an imperative, domain-specific language for data pipelining and analysis using async streams. It can be used as a standalone language or within Rust programs.

use marigold::m;

let odd_digits = m!(
  fn is_odd(i: i32) -> bool {
    i.wrapping_rem(2) == 1
  }

  range(0, 10)
    .filter(is_odd)
    .return
).await.collect::<Vec<_>>().await;

println!("{:?}", odd_digits); // [1, 3, 5, 7, 9]

Quickstart

Install

curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/DominicBurkart/marigold/main/install.sh | sh

Or via cargo:

cargo install marigold -F cli

Or from source:

git clone https://github.com/DominicBurkart/marigold.git
cd marigold
cargo install --path marigold -F cli

Hello World

Create hello_world.marigold:

range(0, 5).write_file("/dev/stdout", csv)

Run it:

marigold run hello_world.marigold

Output:

0
1
2
3
4

Returning results

A program that ends in .return hands its items to the command line: marigold run prints each one on its own line as JSON (JSON Lines), then exits.

fn double(x: i32) -> i32 { x * 2 }

range(0, 4).map(double).return
marigold run double.marigold

Output:

0
2
4
6

Numbers print as plain numbers, strings as quoted JSON strings, arrays as JSON arrays ([1,2]) and structs as JSON objects ({"x":0,"y":1}). Use write_file with csv when a program should produce CSV rows. A program may mix .return and write_file streams: the returned items are printed and the files are written. When a program has several .return streams, their items are interleaved as they arrive, so the order across streams is unspecified.

marigold run builds the program against the published marigold crate that matches the installed CLI version. To build against a local checkout instead, set MARIGOLD_WORKSPACE_PATH to the checkout's marigold crate directory.

Static Analysis

Marigold can statically analyze your program's complexity:

marigold analyze hello_world.marigold
{
  "streams": [
    {
      "description": "input.write_file(...)",
      "cardinality": "5",
      "time_class": "O(1)",
      "exact_time": "O(1)",
      "space_class": "O(1)",
      "exact_space": "O(1)",
      "collects_input": false
    }
  ],
  "program_time": "O(1)",
  "program_exact_time": "O(1)",
  "program_space": "O(1)",
  "program_exact_space": "O(1)",
  "program_cardinality": "5"
}

Editor and Agent Integration

Marigold ships an optional language server, marigold-lsp, that reports diagnostics for .marigold files and supports go-to-definition, references, rename, symbols and hover (with a complexity estimate). None of it is needed to build or run Marigold programs.

Install the server from a clone of this repository:

cargo install --path marigold-lsp

Then connect your tool using the matching directory under integrations/: Claude Code (plugin), opencode (lsp config), Codex (MCP server and AGENTS.md) and pi (extension). marigold-lsp mcp serves the same checks, symbols and complexity estimates as MCP tools for agents without an LSP client.

For tools that can only run shell commands, build the CLI with -F cli and run:

marigold check hello_world.marigold
marigold check --format json hello_world.marigold

Diagnostics have three levels. Errors make the program invalid and the command exit 1. Warnings flag likely mistakes, such as a stream variable read before it is declared. Information covers names that may be Rust items in scope inside m!(), such as an undeclared function, and can be ignored in that case. Warnings and information leave the exit code at 0, so read them as well.

Opt-in telemetry annotations (observed inputs, runs and errors per stream node) are described in integrations/telemetry.

Runtimes

By default, Marigold works in a single future and can work with any runtime.

The tokio and async-std features allow Marigold to spawn additional tasks, enabling parallelism for multithreaded runtimes.

Marigold supports async tracing, e.g. with tokio-console.

Platforms

Marigold's CI builds against aarch64, arm, WASM, and x86 targets, and builds the x86 target in mac and windows environments.

About

Marigold is a programming language for operating on async streams that compiles to Rust πŸ΅οΈπŸ¦€

Topics

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages