Documentation

TypeDB.Decode

Decoding answers #

A RowDecoder α reads named columns of a concept row and builds an α. Decoders compose as an applicative, and every decoder knows up front which columns it reads and which parts of each concept it needs (its plan). The query layer hands the plan to the native batch call, which returns exactly those concepts for many rows at once.

FromConcept says how one column becomes a Lean value. deriving FromRow (see TypeDB.Deriving.FromRow) maps each structure field to the query variable of the same name.

Column flag, Lean side only: resolve the UTC offset of IANA-zoned datetimes.

Equations
Instances For

    How one column of a row becomes a Lean value.

    • expected : String

      The expected shape, for decode errors ("string", "entity", …).

    • flags : UInt8

      Which parts of the concept the native layer must read (see Native.wantLabel).

    • decode : Concept → Except String α

      The value, or a description of what the concept is instead.

    Instances
      @[instance_reducible]
      def TypeDB.FromConcept.ofValue {α : Type} (expected : String) (f : Value → Option α) (flags : UInt8 := 0) :

      Decodes the value of an attribute or value concept with f.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        @[instance_reducible]

        Rejects negative integers.

        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]

        A Std.Time.DateTime at the value's offset; see DatetimeTZ.toDateTime.

        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]
        Equations
        @[instance_reducible]
        Equations
        • One or more equations did not get rendered due to their size.
        @[instance_reducible]

        The whole concept, with its label and IID.

        Equations
        structure TypeDB.Label :

        The type label of a concept: an instance's type, or a type itself.

        Instances For
          def TypeDB.instDecidableEqLabel.decEq (x✝ x✝¹ : Label) :
          Decidable (x✝ = x✝¹)
          Equations
          Instances For
            @[instance_reducible]
            Equations
            @[instance_reducible]
            Equations
            • One or more equations did not get rendered due to their size.
            structure TypeDB.RowDecoder (α : Type) :

            Reads columns of a concept row. columns lists, in order, the variables it reads and the flags for each; run gets the concepts for those columns starting at offset.

            Instances For
              @[instance_reducible]
              Equations
              • One or more equations did not get rendered due to their size.
              @[instance_reducible]
              Equations
              • One or more equations did not get rendered due to their size.
              def TypeDB.RowDecoder.guard {α : Type} (ok : α → Bool) (err : α → TypeDBError) (d : RowDecoder α) :

              Fails the decode of every row with err if ok is false.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Column names and per-column flags, as the native batch call takes them.

                Equations
                Instances For
                  def TypeDB.col {α : Type} (name : String) [i : FromConcept α] :

                  The required column name.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def TypeDB.colOpt {α : Type} (name : String) [i : FromConcept α] :

                    The optional column name: none when the row leaves it empty (e.g. from a try).

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      How a structure field reads its column; Option fields are optional.

                      Instances
                        @[instance_reducible, instance 100]
                        Equations
                        class TypeDB.FromRow (α : Type) :

                        Types decoded from a whole row. Derive it for structures with deriving FromRow.

                        Instances
                          structure TypeDB.Col (name : String) (α : Type) :

                          A single named column.

                          • val : α
                          Instances For
                            @[instance_reducible]
                            instance TypeDB.instReprCol {name✝ : String} {α✝ : Type} [Repr α✝] :
                            Repr (Col name✝ α✝)
                            Equations
                            def TypeDB.instReprCol.repr {name✝ : String} {α✝ : Type} [Repr α✝] :
                            Col name✝ α✝ → Nat → Std.Format
                            Equations
                            Instances For
                              @[instance_reducible]
                              instance TypeDB.instInhabitedCol {a✝ : String} {a✝¹ : Type} [Inhabited a✝¹] :
                              Inhabited (Col a✝ a✝¹)
                              Equations
                              @[instance_reducible]
                              instance TypeDB.instFromRowColOfFromConcept {name : String} {α : Type} [FromConcept α] :
                              FromRow (Col name α)
                              Equations
                              @[instance_reducible]
                              instance TypeDB.instFromRowProd {α β : Type} [FromRow α] [FromRow β] :
                              FromRow (α × β)
                              Equations