Skip to main content

Module parse_emit_protolens

Module parse_emit_protolens 

Source
Expand description

The parse / decorate / emit lens packaged as a first-class panproto-lens::Protolens.

The protolens describes the schema-level relationship between abstract and decorated schemas. The parse / decorate / emit lens packaged as a first-class Protolens.

For every registered grammar G, parse_emit_protolens() returns a Protolens whose source endofunctor strips the layout enrichment fibre (yielding an abstract schema) and whose target endofunctor adds it back via the registered LayoutEnricher.

source theory  F(S) = StripEnrichment(Layout)(S)    -- the forgetful U
target theory  G(S) = AddEnrichment(Layout, π)(S)   -- a section of U
complement       = layout fibre (per-vertex witness)

§What this protolens is, and is not

The Protolens returned here is the schema-level description of the parse/decorate/emit relationship: it documents which constraint sorts belong to the layout fibre, which synthesis driver populates them, and what policy the put-direction uses. It composes with every other protolens in panproto-lens for reasoning about chain laws.

The operational entry points for actually rendering or reconstructing source bytes are ParserRegistry::decorate, ParserRegistry::pretty_with_protocol, and ParserRegistry::emit_pretty_with_protocol — not Protolens::instantiate. The reason is that the parse-side walker invents fresh vertex IDs that the lens framework’s WInstance-level get/put cannot align with the source schema’s IDs; the underlying mismatch is intrinsic to grammars that consolidate tokens (e.g. lilypond’s note pitches) at parse time. The schema-level descriptive content of the protolens remains useful for chain reasoning even when the lens framework’s instance-level migration semantics are not the right fit.

Functions§

parse_emit_protolens
Build a Protolens for the parse / decorate / emit relationship at grammar under the given policy.