pattern
Safe HaskellSafe-Inferred
LanguageHaskell2010

Pattern.RepresentationMap

Description

Invertible mappings between named pattern kinds.

A RepresentationMap names a pair of compatible structural transforms between two PatternKinds. The map itself carries only executable behavior and its round-trip witness. Explanatory metadata about how a map works is deferred for a later design that can express declarative, checkable claims rather than inline prose attached to the value.

Synopsis

Documentation

data RepresentationMap v Source #

A named, invertible mapping between two pattern kinds.

A RepresentationMap is the executable form of an isomorphism between named shapes. forward and inverse are the two morphism components, while roundTrip is the machine-checkable witness that the mapping preserves information on the domain kind.

Invariants for domain-kind inputs:

  • forward should produce a pattern accepted by codomain.
  • roundTrip should hold.
  • When roundTrip holds, (inverse m q . forward m q) p == p structurally.

Notes:

  • Scope remains polymorphic, so maps are not tied to a particular backing representation.
  • Declarative, machine-checkable claims about map-specific encoding choices are deferred; for now those details live in documentation and tests next to concrete maps.

Constructors

RepresentationMap 

Fields

compose :: RepresentationMap v -> RepresentationMap v -> Either String (RepresentationMap v) Source #

Compose two compatible representation maps.

Composition is defined only when the codomain kind of the first map has the same kindName as the domain kind of the second. The resulting map keeps the first domain, the second codomain, composes forward left-to-right, composes inverse right-to-left, and preserves round-trip validation in the same order.

Categorical note: this is morphism composition for the category whose objects are PatternKinds and whose isomorphisms are RepresentationMaps.