Documentation

Lean.Util.MonadCache

class Lean.MonadCache (α β : Type) (m : TypeType) :

Interface for caching results.

  • findCached? : αm (Option β)
  • cache : αβm Unit
Instances
    @[inline]
    def Lean.checkCache {α β : Type} {m : TypeType} [Lean.MonadCache α β m] [Monad m] (a : α) (f : Unitm β) :
    m β

    If entry a := b is already in the cache, then return b. Otherwise, execute b ← f (), store a := b in the cache and return b.

    Equations
    Instances For
      instance Lean.instMonadCacheReaderT {α β ρ : Type} {m : TypeType} [Lean.MonadCache α β m] :
      Equations
      @[always_inline]
      instance Lean.instMonadCacheExceptTOfMonad {α β ε : Type} {m : TypeType} [Lean.MonadCache α β m] [Monad m] :
      class Lean.MonadHashMapCacheAdapter (α β : Type) (m : TypeType) [BEq α] [Hashable α] :

      Adapter for implementing MonadCache interface using HashMaps. We just have to specify how to extract/modify the HashMap.

      Instances
        @[inline]
        def Lean.MonadHashMapCacheAdapter.findCached? {α β : Type} {m : TypeType} [BEq α] [Hashable α] [Monad m] [Lean.MonadHashMapCacheAdapter α β m] (a : α) :
        m (Option β)
        Instances For
          @[inline]
          def Lean.MonadHashMapCacheAdapter.cache {α β : Type} {m : TypeType} [BEq α] [Hashable α] [Lean.MonadHashMapCacheAdapter α β m] (a : α) (b : β) :
          Instances For
            def Lean.MonadCacheT {ω : Type} (α β : Type) (m : TypeType) [STWorld ω m] [BEq α] [Hashable α] :
            Equations
            Instances For
              @[inline]
              def Lean.MonadCacheT.run {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] [MonadLiftT (ST ω) m] [Monad m] {σ : Type} (x : Lean.MonadCacheT α β m σ) :
              m σ
              Instances For
                instance Lean.MonadCacheT.instMonad {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] [Monad m] :
                Equations
                instance Lean.MonadCacheT.instMonadLift {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] :
                instance Lean.MonadCacheT.instMonadControl {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] :
                instance Lean.MonadCacheT.instMonadFinally {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] [MonadFinally m] :
                Equations
                instance Lean.MonadCacheT.instMonadRef {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] [Lean.MonadRef m] :
                Equations
                instance Lean.MonadCacheT.instAlternative {ω α β : Type} {m : TypeType} [STWorld ω m] [BEq α] [Hashable α] [Monad m] [Alternative m] :
                def Lean.MonadStateCacheT (α β : Type) (m : TypeType) [BEq α] [Hashable α] :
                Instances For
                  Equations
                  • Lean.MonadStateCacheT.instMonadHashMapCacheAdapter = { getCache := get, modifyCache := fun (f : Std.HashMap α βStd.HashMap α β) => modify f }
                  @[inline]
                  def Lean.MonadStateCacheT.run {α β : Type} {m : TypeType} [BEq α] [Hashable α] [Monad m] {σ : Type} (x : Lean.MonadStateCacheT α β m σ) :
                  m σ
                  Instances For
                    instance Lean.MonadStateCacheT.instMonad {α β : Type} {m : TypeType} [BEq α] [Hashable α] [Monad m] :
                    instance Lean.MonadStateCacheT.instMonadExceptOf {α β : Type} {m : TypeType} [BEq α] [Hashable α] [Monad m] (ε : Type u_1) [MonadExceptOf ε m] :
                    Equations