Theory Lenses_And_Other_Optics.Prism
theory Prism
imports Main "HOL-Library.Datatype_Records"
begin
named_theorems focus_rules
named_theorems focus_intros
named_theorems focus_elims
named_theorems focus_simps
named_theorems focus_components
section‹Prisms›
text‹Prisms are types that describe how one type acts as a subtype of another. They are defined as a
pair of an embedding of the subtype into the larger, compound type, and a partial projection
in the other direction. If lenses describe the interaction of modifications and reads of deeply-nested
fields within a record or product-like type, then prisms describe the interactions of modifications
and reads of deeply-nested fields within a sum-like type, such as a disjoint union.
Mathematically, one can think of prisms as ∗‹subsets/embeddings›.›