1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2024-2026 Jonathan Shook
// SPDX-License-Identifier: Apache-2.0
//! Polydat — a variates construction engine: one function graph,
//! compiled from Polydat source or built programmatically, run on the
//! interpreter, as closures, or as native code, with the same values
//! on every engine.
//!
//! This crate is the facade over three crates and re-exports each at
//! the paths it always had: [`polydat_grammar`] (the language),
//! [`polydat_core`] (the runtime), and [`polydat_nodes`] (the node
//! library, under [`library`] beside the nodes the core keeps). A
//! program that compiles against `polydat` sees one crate.
//!
//! # Quick start
//!
//! ## From DSL source
//!
//! The simplest way to build a kernel is from Polydat DSL source, on the
//! default engine (native code with the `jit` feature, closures without):
//!
//! ```rust
//! use polydat::dsl::compile_polydat_kernel;
//!
//! let mut kernel = compile_polydat_kernel(r#"
//! input cycle: u64
//! hashed := hash(cycle)
//! user_id := mod(hashed, 1000000)
//! "#).unwrap();
//!
//! kernel.set_inputs(&[42]);
//! let user_id = kernel.pull("user_id").as_u64();
//! assert!(user_id < 1_000_000);
//! ```
//!
//! ## From the assembler API
//!
//! For programmatic construction:
//!
//! ```rust
//! use polydat::compile::assembly::{PolydatAssembler, WireRef};
//! use polydat::library::hash::Hash;
//! use polydat::library::arithmetic::Mod;
//!
//! let mut asm = PolydatAssembler::new(vec!["cycle".into()]);
//! asm.add_node("hashed", Box::new(Hash::new()), vec![WireRef::input("cycle")]);
//! asm.add_node("user_id", Box::new(Mod::new(1_000_000)), vec![WireRef::node("hashed")]);
//! asm.add_output("user_id", WireRef::node("user_id"));
//!
//! let mut kernel = asm.compile().unwrap();
//! kernel.set_inputs(&[42]);
//! assert!(kernel.pull("user_id").as_u64() < 1_000_000);
//! ```
//!
//! (The crate runs no doctests; both examples are
//! `tests/rustdoc_examples.rs`.)
//!
//! # Documentation
//!
//! The rustdoc covers the API. The narrative documentation lives in the
//! repository under `crates/polydat/docs/`, organized by the
//! [documentation index](https://github.com/nosqlbench/polydat/blob/main/crates/polydat/docs/README.md).
pub use ;
/// The node library: the nodes the compiler keeps
/// (`polydat_core::library`) and the node library (`polydat_nodes`),
/// side by side at the paths they always had.