lean2js

Lean2Js.EncDeriving

source

Imports 3

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.

def

Lean2Js.Enc.discriminator

source

The 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
      opaque

      Lean2Js.Enc.discriminatorAttr

      source
      Used by
        def

        Lean2Js.Enc.foldOf

        source

        The 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
        Instances For
          Used by
            opaque

            Lean2Js.Enc.foldOfAttr

            source
            Used by
              def

              Lean2Js.Enc.foldOf?

              source

              The type a fold walks, where the declaration carries the mark deriving Enc put on it.

              Equations
              Instances For
                Used by
                  instance

                  Lean2Js.Enc.instInhabitedFieldKind

                  source
                  @[instance_reducible]
                  Equations
                  Used by
                    def

                    Lean2Js.Enc.instBEqFieldKind.beq

                    source
                    Equations
                    Instances For
                      Used by
                        instance

                        Lean2Js.Enc.instBEqFieldKind

                        source
                        @[instance_reducible]
                        Equations
                        Used by
                          abbrev

                          _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.name

                          source
                          @[reducible]
                          Equations
                          Instances For
                            Used by
                              abbrev

                              _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.fields

                              source
                              @[reducible]
                              Equations
                              Instances For
                                Used by
                                  abbrev

                                  _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.CtorShape.kinds

                                  source
                                  @[reducible]
                                  Equations
                                  Instances For
                                    Used by
                                      instance

                                      Lean2Js.Enc.instInhabitedCtorShape

                                      source
                                      @[instance_reducible]
                                      Equations
                                      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.

                                        abbrev

                                        _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.p

                                        source
                                        @[reducible]
                                        Equations
                                        Instances For
                                          Used by
                                            abbrev

                                            _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.env

                                            source
                                            @[reducible]
                                            Equations
                                            Instances For
                                              Used by
                                                abbrev

                                                _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.nameLit

                                                source
                                                @[reducible]
                                                Equations
                                                Instances For
                                                  Used by
                                                    abbrev

                                                    _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.typeDefId

                                                    source
                                                    @[reducible]
                                                    Equations
                                                    Instances For
                                                      Used by
                                                        abbrev

                                                        _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.toValueId

                                                        source
                                                        @[reducible]
                                                        Equations
                                                        Instances For
                                                          Used by
                                                            abbrev

                                                            _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldId

                                                            source
                                                            @[reducible]
                                                            Equations
                                                            Instances For
                                                              Used by
                                                                abbrev

                                                                _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldListId

                                                                source
                                                                @[reducible]
                                                                Equations
                                                                Instances For
                                                                  Used by
                                                                    abbrev

                                                                    _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.foldAltsId

                                                                    source
                                                                    @[reducible]
                                                                    Equations
                                                                    Instances For
                                                                      Used by
                                                                        abbrev

                                                                        _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.denotesFoldId

                                                                        source
                                                                        @[reducible]
                                                                        Equations
                                                                        Instances For
                                                                          Used by
                                                                            abbrev

                                                                            _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.denotesFoldListId

                                                                            source
                                                                            @[reducible]
                                                                            Equations
                                                                            Instances For
                                                                              Used by
                                                                                abbrev

                                                                                _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.algebra

                                                                                source
                                                                                @[reducible]
                                                                                Equations
                                                                                Instances For
                                                                                  Used by
                                                                                    abbrev

                                                                                    _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.bodies

                                                                                    source
                                                                                    @[reducible]
                                                                                    Equations
                                                                                    Instances For
                                                                                      Used by
                                                                                        abbrev

                                                                                        _private.Lean2Js.EncDeriving.0.Lean2Js.Enc.FoldCertIds.hyps

                                                                                        source
                                                                                        @[reducible]
                                                                                        Equations
                                                                                        Instances For
                                                                                          Used by