| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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
- data RepresentationMap v = RepresentationMap {
- repMapName :: String
- repMapDomain :: PatternKind v
- repMapCodomain :: PatternKind v
- repMapForward :: forall (q :: Type -> Type). ScopeQuery q v => q v -> Pattern v -> Pattern v
- repMapInverse :: forall (q :: Type -> Type). ScopeQuery q v => q v -> Pattern v -> Pattern v
- repMapRoundTrip :: forall (q :: Type -> Type). ScopeQuery q v => q v -> Pattern v -> Bool
- compose :: RepresentationMap v -> RepresentationMap v -> Either String (RepresentationMap v)
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:
forwardshould produce a pattern accepted bycodomain.roundTripshould hold.- When
roundTripholds,(inverse m q . forward m q) p == pstructurally.
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.