Skip to main content

Crate panproto_lens

Crate panproto_lens 

Source
Expand description

§panproto-lens

Bidirectional lenses via protolens (schema-independent lens families).

Every schema migration is a lens with a get direction (= restrict, projecting data forward) and a put direction (= restore from complement, bringing modifications back). The lens laws (GetPut and PutGet) guarantee round-trip fidelity.

This crate provides:

  • Lens: An asymmetric lens backed by a compiled migration.
  • get / put: Forward and backward lens directions.
  • Complement: Data discarded by get, needed by put.
  • Protolens: A dependent function from schemas to lenses (Π(S : Schema | P(S)). Lens(F(S), G(S))).
  • ProtolensChain: Composable sequence of protolenses.
  • auto_generate: Automatic protolens generation from two schemas.
  • compose(): Compose two lenses sequentially.
  • check_laws: Verify GetPut and PutGet on a test instance.

The mathematical foundations are based on asymmetric lenses with complement (Diskin et al., 2011), GAT-based protolenses (natural transformations between theory endofunctors), and Cambria’s approach to schema evolution (Ink & Switch, 2020).

Re-exports§

pub use asymmetric::Complement;
pub use asymmetric::get;
pub use asymmetric::put;
pub use auto_lens::AutoLensConfig;
pub use auto_lens::AutoLensResult;
pub use auto_lens::Stringency;
pub use auto_lens::auto_generate;
pub use auto_lens::auto_generate_candidates;
pub use auto_lens::auto_generate_candidates_with_hints;
pub use auto_lens::auto_generate_with_hints;
pub use candidate::CandidateStep;
pub use candidate::LensCandidate;
pub use complement_type::CapturedField;
pub use complement_type::ComplementKind;
pub use complement_type::ComplementSpec;
pub use complement_type::DefaultRequirement;
pub use complement_type::chain_complement_spec;
pub use complement_type::complement_spec_at;
pub use compose::compose;
pub use cost::chain_cost;
pub use cost::complement_cost;
pub use cost::verify_identity_cost;
pub use cost::verify_subadditivity;
pub use diff_to_protolens::DiffSpec;
pub use diff_to_protolens::KindChange;
pub use diff_to_protolens::diff_to_lens;
pub use diff_to_protolens::diff_to_protolens;
pub use edit_error::EditLensError;
pub use edit_lens::EditLens;
pub use edit_pipeline::EditPipeline;
pub use edit_provenance::EditProvenance;
pub use error::LawViolation;
pub use error::LensError;
pub use graph::LensGraph;
pub use laws::check_get_put;
pub use laws::check_laws;
pub use laws::check_put_get;
pub use optic::OpticKind;
pub use optic::classify_transform;
pub use optic::refine_scoped_optic;
pub use protolens::ComplementConstructor;
pub use protolens::FleetResult;
pub use protolens::Protolens;
pub use protolens::ProtolensChain;
pub use protolens::SchemaConstraint;
pub use protolens::apply_to_fleet;
pub use protolens::combinators;
pub use protolens::elementary;
pub use protolens::horizontal_compose as protolens_horizontal;
pub use protolens::lift_chain;
pub use protolens::lift_protolens;
pub use protolens::vertical_compose as protolens_vertical;
pub use symbolic::SymbolicStep;
pub use symbolic::simplify_steps;
pub use symmetric::CoherenceViolation;
pub use symmetric::SymmetricLens;

Modules§

asymmetric
Asymmetric lens operations: get and put with complement tracking.
auto_lens
Automatic protolens generation pipeline.
candidate
Ranked candidate lenses with per-step explanations.
coercion_laws
Sample-based verification of declared coercion classes.
complement_type
Complement type system for protolenses.
compose
Lens composition.
cost
Complement cost computation forming a Lawvere metric on lens graphs.
diff_to_protolens
Convert schema diffs into protolens chains.
edit_error
Error types for edit lens operations.
edit_laws
Edit lens law verification.
edit_lens
Edit lens: translates individual edits between source and view schemas.
edit_pipeline
Per-pipeline-step edit translation for the edit lens.
edit_provenance
Provenance tracking for translated edits.
enrichment_registry
Cross-crate extension point for schema-enrichment synthesis.
error
Error types for lens operations.
fibration
Grothendieck fibration structure for the protolens framework.
graph
Weighted lens graph with Floyd-Warshall shortest paths.
hint
Forward-chaining hint propagation for auto-lens generation.
laws
Round-trip law verification for lenses.
layout_complement
The operational layout complement: the per-vertex fibres the emit review (put-direction) consumes.
optic
Optic classification for protolens chains.
protolens
Protolenses: schema-parameterized families of lenses.
symbolic
Symbolic simplification of protolens chains.
symmetric
Symmetric lenses via span composition.

Structs§

Lens
An asymmetric lens with complement tracking.