Documentation

Hale.Vault.Data.Vault

structure Data.Key (α : Type) :

A typed key for vault access. A Key α can only store/retrieve values of type α. Keys are created via Key.new and are globally unique.

$$\text{Key}(\alpha) \cong \mathbb{N}$$

Instances For
    @[implicit_reducible]
    instance Data.instBEqKey {α✝ : Type} [BEq α✝] :
    BEq (Key α✝)
    Equations
    def Data.instBEqKey.beq {α✝ : Type} [BEq α✝] :
    Key α✝Key α✝Bool
    Equations
    Instances For
      @[implicit_reducible]
      instance Data.instHashableKey {α✝ : Type} [Hashable α✝] :
      Hashable (Key α✝)
      Equations
      def Data.instHashableKey.hash {α✝ : Type} [Hashable α✝] :
      Key α✝UInt64
      Equations
      Instances For
        structure Data.Vault :

        A type-safe heterogeneous map. Values of different types can coexist, each accessible only through its corresponding typed Key.

        $$\text{Vault} = \text{HashMap}(\mathbb{N}, \text{Any})$$

        Instances For
          def Data.Key.new {α : Type} :
          IO (Key α)

          Allocate a fresh typed key. Each call returns a distinct key. $$\text{new} : \text{IO}(\text{Key}\ \alpha)$$

          Equations
          Instances For
            @[inline]

            The empty vault. $$\text{empty} : \text{Vault},\quad |\text{empty}| = 0$$

            Equations
            Instances For
              @[implicit_reducible]
              Equations
              @[inline]

              Number of entries in the vault. $$\text{size}(v)$$

              Equations
              Instances For
                @[implemented_by _private.Hale.Vault.Data.Vault.0.Data.Vault.insertImpl]
                opaque Data.Vault.insert {α : Type} (key : Key α) (val : α) (v : Vault) :

                Insert a value into the vault under the given key. If the key already has a value, it is replaced. $$\text{insert}(k, x, v) = v[k \mapsto x]$$

                @[implemented_by _private.Hale.Vault.Data.Vault.0.Data.Vault.lookupImpl]
                opaque Data.Vault.lookup {α : Type} (key : Key α) (v : Vault) :

                Look up the value associated with a key. Returns none if the key is not present. $$\text{lookup}(k, v) = v[k]$$

                @[inline]
                def Data.Vault.delete {α : Type} (key : Key α) (v : Vault) :

                Delete a key and its associated value from the vault. $$\text{delete}(k, v) = v \setminus \{k\}$$

                Equations
                Instances For
                  @[inline]
                  def Data.Vault.adjust {α : Type} (f : αα) (key : Key α) (v : Vault) :

                  Adjust the value at a key, if present. $$\text{adjust}(f, k, v) = \begin{cases} v[k \mapsto f(v[k])] & k \in v \\ v & k \notin v \end{cases}$$

                  Equations
                  Instances For

                    Union of two vaults. Right-biased: values from v2 take precedence. $$\text{union}(v_1, v_2) = v_2 \cup v_1$$

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