Lean2Js.EncDeriving
deriving Enc for the types an author declares #
An author's inductive or structure is not one of the types Lean2Js/Enc.lean knows, so where it sits
inside Value has to be written when the type is. This is that, generated: the Core.TypeDef a program
declares it as, the encoding and its inverse, and the entry check for the values the encoding produces.
Everything the handler emits is a top-level declaration rather than a field of the instance, so each proof is an ordinary equation-style definition over the constructors and the instance is the line that wires them together.
Lean2Js.Enc.discriminator
sourceThe key the generated JavaScript tells a type's constructors apart by, written above the type it belongs to rather than beside the package: which key reads well is a fact about the type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Enc.discriminatorAttr
sourceUsed by
Lean2Js.Enc.foldOf
sourceThe mark deriving Enc puts on the fold it writes for a type that names itself, carrying the name
of the type the fold walks.
A mark rather than a suffix: an author may write their own T.fold, and reading that one as the
generated one would build a certificate about the wrong function.
Equations
- Lean2Js.Enc.foldOf = Lean.ParserDescr.node `Lean2Js.Enc.foldOf 1022 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.nonReservedSymbol "foldOf " false) (Lean.ParserDescr.const `str))
Instances For
Used by
Lean2Js.Enc.foldOfAttr
sourceUsed by
Lean2Js.Enc.foldOf?
sourceThe type a fold walks, where the declaration carries the mark deriving Enc put on it.
Equations
- Lean2Js.Enc.foldOf? env n = Lean2Js.Enc.foldOfAttr.getParam? env n
Instances For
Used by
Lean2Js.Enc.instInhabitedFieldKind
sourceEquations
Used by
Lean2Js.Enc.instBEqFieldKind.beq
sourceEquations
Instances For
Used by
Lean2Js.Enc.instBEqFieldKind
sourceEquations
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.name
sourceEquations
- Lean2Js.Enc.CtorShape.name✝ self = self.1
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.fields
sourceEquations
- Lean2Js.Enc.CtorShape.fields✝ self = self.2
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.kinds
sourceEquations
- Lean2Js.Enc.CtorShape.kinds✝ self = self.3
Instances For
Used by
Lean2Js.Enc.instInhabitedCtorShape
sourceEquations
Used by
A type that names itself #
Enc answers for a type that is already there, and the type being declared is not, so a field whose type
is that one cannot go through the class. Everything below writes such a field's half by hand; the halves
that walk a list of the type sit in a mutual block with the ones that walk the type.
The certificate that the subset's walk computes the fold #
T.fold is written per type, so the theorem that the subset's walk computes it is too: denotes_foldE
abstracts the walk and asks for that theorem as hw, and it is the one step of a fold's descent that
cannot be proved once for every program.
What is generated is an induction over the type, in a mutual block with the List T half — the move
ofValue_toValue / ofValues_map already makes. One constructor's case reads the node, then its fields
left to right, then which alternative fires, and hands what is left to that constructor's own hypothesis.
A field that comes round splits on whether its walk answered, so every step after it sits inside that
split, which is why a case is assembled from its last field back.
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.p
sourceEquations
- Lean2Js.Enc.FoldCertIds.p✝ self = self.1
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.env
sourceEquations
- Lean2Js.Enc.FoldCertIds.env✝ self = self.2
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.nameLit
sourceEquations
- Lean2Js.Enc.FoldCertIds.nameLit✝ self = self.3
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.typeDefId
sourceEquations
- Lean2Js.Enc.FoldCertIds.typeDefId✝ self = self.4
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.toValueId
sourceEquations
- Lean2Js.Enc.FoldCertIds.toValueId✝ self = self.5
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldId
sourceEquations
- Lean2Js.Enc.FoldCertIds.foldId✝ self = self.6
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldListId
sourceEquations
- Lean2Js.Enc.FoldCertIds.foldListId✝ self = self.7
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldAltsId
sourceEquations
- Lean2Js.Enc.FoldCertIds.foldAltsId✝ self = self.8
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.denotesFoldId
sourceEquations
- Lean2Js.Enc.FoldCertIds.denotesFoldId✝ self = self.9
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.denotesFoldListId
sourceEquations
- Lean2Js.Enc.FoldCertIds.denotesFoldListId✝ self = self.10
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.algebra
sourceEquations
- Lean2Js.Enc.FoldCertIds.algebra✝ self = self.11
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.bodies
sourceEquations
- Lean2Js.Enc.FoldCertIds.bodies✝ self = self.12
Instances For
Used by
_private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.hyps
sourceEquations
- Lean2Js.Enc.FoldCertIds.hyps✝ self = self.13