Documentation

Lake.Util.Store

class Lake.MonadStore1Of {κ : Type u} (k : κ) (α : semiOutParam (Type v)) (m : Type v → Type w) :
Type (max v w)

A monad equipped with a dependently typed key-value store for a particular key.

Instances
    class Lake.MonadStore1 {κ : Type u} (k : κ) (α : outParam (Type v)) (m : Type v → Type w) :
    Type (max v w)

    Similar to MonadStore1Of, but α is an outParam for convenience.

    Instances
      @[instance_reducible]
      instance Lake.instMonadStore1OfMonadStore1Of {κ✝ : Type u_1} {k : κ✝} {α : Type u_2} {m : Type u_2 → Type u_3} [MonadStore1Of k α m] :
      Equations
      class Lake.MonadDStore (κ : Type u) (β : semiOutParam (κ → Type v)) (m : Type v → Type w) :
      Type (max (max u v) w)

      A monad equipped with a dependently typed key-object store.

      • fetch? (key : κ) : m (Option (β key))
      • store (key : κ) : β key → m PUnit
      Instances
        @[instance_reducible]
        instance Lake.instMonadStore1OfOfMonadDStore {κ : Type u_1} {β : κ → Type u_2} {m : Type u_2 → Type u_3} {k : κ} [MonadDStore κ β m] :
        MonadStore1Of k (β k) m
        Equations
        @[reducible, inline]
        abbrev Lake.MonadStore (κ : Type u_1) (α : Type u_2) (m : Type u_2 → Type u_3) :
        Type (max (max u_1 u_2) u_3)

        A monad equipped with a key-object store.

        Equations
        Instances For
          @[instance_reducible]
          instance Lake.instMonadDStoreOfMonadLift {m : Type u_1 → Type u_2} {n : Type u_1 → Type u_3} {κ : Type u_4} {β : κ → Type u_1} [MonadLift m n] [MonadDStore κ β m] :
          MonadDStore κ β n
          Equations
          @[inline]
          def Lake.fetchOrCreateNonatomic {m : Type u_1 → Type u_2} {κ : Type u_3} {α : Type u_1} [Monad m] (key : κ) [MonadStore1Of key α m] (create : m α) :
          m α

          Returns the value of key in the store if it exists. Otherwise, runs create to generate it, adds it to the store, and returns the result.

          Note: This implementation does not update the store atomically.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[reducible, inline, deprecated Lake.fetchOrCreateNonatomic (since := "2026-11-14")]
            abbrev Lake.fetchOrCreate {m : Type u_1 → Type u_2} {κ : Type u_3} {α : Type u_1} [Monad m] (key : κ) [MonadStore1Of key α m] (create : m α) :
            m α

            Returns the value of key in the store if it exists. Otherwise, runs create to generate it, adds it to the store, and returns the result.

            Note: This implementation does not update the store atomically.

            Equations
            Instances For