Expand description
§Orlando: Compositional Data Transformation
Orlando is a high-performance data transformation library that implements transducers in Rust, compiling to WebAssembly for use in JavaScript applications.
§What are Transducers?
Transducers compose transformations, not data. Instead of creating intermediate collections:
data → map → [intermediate] → filter → [intermediate] → resultWe compose operations first, then execute in a single pass:
(map ∘ filter) → data → resultThis approach:
- Eliminates intermediate allocations - No temporary arrays between operations
- Enables early termination - Operations like
takecan stop processing immediately - Composes efficiently - Build complex pipelines from simple parts
- Executes in a single pass - Process each element only once
§Category Theory Foundation
Transducers are natural transformations between fold functors. Given a reducing
function R: (Acc, Out) -> Acc, a transducer transforms it into a new reducing
function (Acc, In) -> Acc.
Formally, a transducer is a polymorphic function:
∀Acc. ((Acc, Out) -> Acc) -> ((Acc, In) -> Acc)This mathematical foundation ensures that transducers compose correctly and satisfy important laws like associativity and identity.
§Usage (Rust)
use orlando_transducers::transforms::{Map, Filter, Take};
use orlando_transducers::collectors::to_vec;
use orlando_transducers::transducer::Transducer;
// Build a pipeline
let pipeline = Map::new(|x: i32| x * 2)
.compose(Filter::new(|x: &i32| x % 3 == 0))
.compose(Take::new(5));
// Execute in a single pass
let result = to_vec(&pipeline, 1..100);
// result: [6, 12, 18, 24, 30]§Usage (JavaScript via WASM)
import { Pipeline } from './pkg/orlando.js';
const pipeline = new Pipeline()
.map(x => x * 2)
.filter(x => x % 3 === 0)
.take(5);
const result = pipeline.toArray([...Array(100).keys()].map(x => x + 1));
// result: [6, 12, 18, 24, 30]§Performance
Orlando leverages:
- Zero-cost abstractions - Rust’s monomorphization eliminates abstraction overhead
- WASM SIMD - Vectorized operations for numeric data
- Early termination - Stop processing as soon as possible
- Single-pass execution - No intermediate allocations
Benchmarks show 3-5x performance improvement over pure JavaScript array chaining.
Re-exports§
pub use step::cont;pub use step::is_stopped;pub use step::stop;pub use step::unwrap_step;pub use step::Step;pub use transducer::Compose;pub use transducer::Identity;pub use transducer::Transducer;pub use transforms::Aperture;pub use transforms::Chunk;pub use transforms::Drop;pub use transforms::DropWhile;pub use transforms::Filter;pub use transforms::FlatMap;pub use transforms::Interpose;pub use transforms::Map;pub use transforms::Reject;pub use transforms::RepeatEach;pub use transforms::Scan;pub use transforms::Take;pub use transforms::TakeWhile;pub use transforms::Tap;pub use transforms::Unique;pub use transforms::UniqueBy;pub use collectors::cartesian_product;pub use collectors::contains;pub use collectors::count;pub use collectors::cycle;pub use collectors::difference;pub use collectors::drop_last;pub use collectors::every;pub use collectors::find;pub use collectors::first;pub use collectors::frequencies;pub use collectors::group_by;pub use collectors::intersection;pub use collectors::last;pub use collectors::max;pub use collectors::max_by;pub use collectors::mean;pub use collectors::median;pub use collectors::merge;pub use collectors::min;pub use collectors::min_by;pub use collectors::mode;pub use collectors::none;pub use collectors::partition;pub use collectors::partition_by;pub use collectors::product;pub use collectors::quantile;pub use collectors::range;pub use collectors::reduce;pub use collectors::repeat;pub use collectors::reservoir_sample;pub use collectors::reverse;pub use collectors::some;pub use collectors::sort_by;pub use collectors::sort_with;pub use collectors::std_dev;pub use collectors::sum;pub use collectors::symmetric_difference;pub use collectors::take_last;pub use collectors::to_vec;pub use collectors::top_k;pub use collectors::unfold;pub use collectors::union;pub use collectors::variance;pub use collectors::zip;pub use collectors::zip_longest;pub use collectors::zip_with;pub use logic::all_pass;pub use logic::any_pass;pub use logic::both;pub use logic::complement;pub use logic::either;pub use logic::IfElse;pub use logic::Unless;pub use logic::When;pub use optics::ComposedLens;pub use optics::Fold;pub use optics::Iso;pub use optics::Lens;pub use optics::Optional;pub use optics::Prism;pub use optics::Traversal;pub use geometric_optics::blade_grade;pub use geometric_optics::blades_at_grade_count;pub use geometric_optics::component_get;pub use geometric_optics::component_set;pub use geometric_optics::grade_extract;pub use geometric_optics::grade_indices;pub use geometric_optics::grade_involution;pub use geometric_optics::grade_mask;pub use geometric_optics::grade_project;pub use geometric_optics::grade_project_max;pub use geometric_optics::has_grade;pub use geometric_optics::is_pure_grade;pub use geometric_optics::norm;pub use geometric_optics::norm_squared;pub use geometric_optics::normalize;
Modules§
- collectors
- Terminal operations (collectors) for transducers.
- geometric_
optics - Geometric Optics: Algebra-Aware Data Access
- iter_
ext - Iterator Extension for Transducers
- logic
- Logic functions for predicate composition and conditional transformations.
- optics
- Optics: Functional Lenses for Immutable Data Access
- profunctor
- Profunctor types re-exported from Karpal.
- signal
- Signal: A time-varying reactive value
- simd
- SIMD-accelerated operations for transducers.
- step
- The Step monad for early termination in transducer chains.
- stream
- Stream: A push-based event stream
- transducer
- Core transducer trait and composition.
- transforms
- Standard transducer transformations.