lemma-engine 0.8.7

A language that means business.
Documentation
//! # Lemma Engine
//!
//! **Rules for man and machine**
//!
//! Lemma is a declarative programming language for expressing rules, facts, and business logic
//! in a way that is both human-readable and machine-executable.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use lemma::{Engine, SourceType};
//! use std::collections::HashMap;
//!
//! let mut engine = Engine::new();
//!
//! // Load Lemma code
//! engine.load(r#"
//!     spec example
//!     fact price: 100
//!     fact quantity: 5
//!     rule total: price * quantity
//! "#, SourceType::Labeled("example.lemma")).expect("failed to load");
//!
//! // Evaluate the spec (all rules, no fact values)
//! let now = lemma::DateTimeValue::now();
//! let response = engine.run("example", Some(&now), HashMap::new(), false).unwrap();
//! ```
//!
//! ## Core Concepts
//!
//! ### Specs
//! A spec is a collection of facts and rules. Specs can reference
//! other specs to build composable logic.
//!
//! ### Facts
//! Facts are named values: numbers, text, dates, booleans, or typed units
//! like `50 kilograms` or `100`.
//!
//! ### Rules
//! Rules compute values based on facts and other rules. They support
//! conditional logic through "unless" clauses.
//!
//! ### Types
//! Lemma has a rich type system including units (mass, length, time, money)
//! with automatic conversions.

#[cfg(test)]
mod tests;

pub(crate) mod computation;
pub mod engine;
pub mod error;
pub mod evaluation;
pub mod formatting;
pub mod inversion;
pub mod limits;
pub(crate) mod literals;
pub mod parsing;
pub mod planning;
pub mod registry;
pub mod serialization;
pub mod spec_id;

#[cfg(target_arch = "wasm32")]
pub mod wasm;

pub use engine::{Context, Engine, Errors, SourceType};
pub use error::{Error, RequestErrorKind};
pub use evaluation::explanation;
pub use evaluation::operations::{
    ComputationKind, OperationKind, OperationRecord, OperationResult,
};
pub use evaluation::response::{Facts, Response, RuleResult};
pub use formatting::{format_source, format_specs};
pub use inversion::{Bound, Domain, InversionResponse, Solution, Target, TargetOp};
pub use limits::ResourceLimits;
pub use parsing::ast::{
    DateTimeValue, DepthTracker, LemmaFact, LemmaRule, LemmaSpec, MetaField, MetaValue, Span,
    TypeDef,
};
pub use parsing::parse;
pub use parsing::ParseResult;
pub use parsing::Source;
pub use planning::semantics::{
    is_same_spec, FactPath, LemmaType, LiteralValue, RatioUnit, RatioUnits, RulePath, ScaleUnit,
    ScaleUnits, SemanticDurationUnit, TypeDefiningSpec, TypeSpecification, ValueKind,
};
pub use planning::{ExecutionPlan, PlanningResult, SpecPlanningResult, SpecSchema};
#[cfg(feature = "registry")]
pub use registry::LemmaBase;
pub use registry::{
    resolve_registry_references, Registry, RegistryBundle, RegistryError, RegistryErrorKind,
};
pub use spec_id::parse_spec_id;