Documentation

ArkLib.Data.Math.HList

Heterogeneous Lists #

We define HList as a synonym for List (Σ α : Type u, α), namely a list of types together with a value.

We note some other implementations of HList:

Our choice of definition is so that we can directly rely on the existing API for List.

@[reducible, inline]
abbrev HList :
Type (u + 1)

Heterogeneous list

Equations
Instances For
    Equations
    Instances For
      def HList.cons (x : (α : Type u) × α) (xs : HList) :
      Equations
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem HList.cons_eq_List.cons {x : (α : Type u) × α} {xs : HList} :
          x ::ₕ xs = x :: xs
          @[simp]
          theorem HList.length_cons (x : (α : Type u) × α) (xs : HList) :

          Returns the types of the elements in the HList

          Equations
          Instances For
            @[simp]
            theorem HList.getTypes_cons (x : (α : Type u) × α) (xs : HList) :
            getTypes (x :: xs) = x.fst :: xs.getTypes
            @[simp]
            theorem HList.getTypes_hcons (x : (α : Type u) × α) (xs : HList) :
            @[simp]
            def HList.getValue (l : HList) (i : Fin (List.length l)) :

            Get the value of the element at index i, of type l[i].1

            Equations
            Instances For
              @[simp]
              theorem List.get_nil {α : Type u} (i : Fin 0) (a : α) :
              [].get i = a
              def DVec {m : Type v} (α : mType u) :
              Type (max u v)

              Dependent vectors

              Equations
              • DVec α = ((i : m) → α i)
              Instances For
                def HList.toDVec (l : HList) :
                DVec fun (i : Fin (List.length l)) => l[i].fst

                Convert a HList to a DVec

                Equations
                Instances For
                  def HList.ofDVec {n : } {α : Fin nType u} (l : DVec α) :

                  Create an HList from a DVec

                  Equations
                  Instances For
                    theorem HList.toDVec_eq_getValue (l : HList) (i : Fin (List.length l)) :
                    l.toDVec i = l.getValue i

                    Equivalent between HList.getValue and HList.toDVec