@[inline]
def
Lean.checkCache
{α : Type}
{β : Type}
{m : Type → Type}
[Lean.MonadCache α β m]
[Monad m]
(a : α)
(f : Unit → m β)
:
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
.
Instances For
instance
Lean.instMonadCacheReaderT
{α : Type}
{β : Type}
{ρ : Type}
{m : Type → Type}
[Lean.MonadCache α β m]
:
Lean.MonadCache α β (ReaderT ρ m)
@[always_inline]
instance
Lean.instMonadCacheExceptT
{α : Type}
{β : Type}
{ε : Type}
{m : Type → Type}
[Lean.MonadCache α β m]
[Monad m]
:
Lean.MonadCache α β (ExceptT ε m)
- getCache : m (Lean.HashMap α β)
- modifyCache : (Lean.HashMap α β → Lean.HashMap α β) → m Unit
Adapter for implementing MonadCache
interface using HashMap
s.
We just have to specify how to extract/modify the HashMap
.
Instances
@[inline]
def
Lean.MonadHashMapCacheAdapter.cache
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Lean.MonadHashMapCacheAdapter α β m]
(a : α)
(b : β)
:
m Unit
Instances For
instance
Lean.MonadHashMapCacheAdapter.instMonadCache
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
[Lean.MonadHashMapCacheAdapter α β m]
:
Lean.MonadCache α β m
instance
Lean.MonadCacheT.instMonadHashMapCacheAdapterMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
[MonadLiftT (ST ω) m]
[Monad m]
:
Lean.MonadHashMapCacheAdapter α β (Lean.MonadCacheT α β m)
@[inline]
def
Lean.MonadCacheT.run
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
[MonadLiftT (ST ω) m]
[Monad m]
{σ : Type}
(x : Lean.MonadCacheT α β m σ)
:
m σ
Instances For
instance
Lean.MonadCacheT.instMonadExceptOfMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
(ε : Type u_1)
[MonadExceptOf ε m]
:
MonadExceptOf ε (Lean.MonadCacheT α β m)
instance
Lean.MonadCacheT.instMonadControlMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
:
MonadControl m (Lean.MonadCacheT α β m)
instance
Lean.MonadCacheT.instMonadFinallyMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
[Monad m]
[MonadFinally m]
:
MonadFinally (Lean.MonadCacheT α β m)
instance
Lean.MonadCacheT.instMonadRefMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
[Monad m]
[Lean.MonadRef m]
:
Lean.MonadRef (Lean.MonadCacheT α β m)
instance
Lean.MonadCacheT.instAlternativeMonadCacheT
{ω : Type}
{α : Type}
{β : Type}
{m : Type → Type}
[STWorld ω m]
[BEq α]
[Hashable α]
[Monad m]
[Alternative m]
:
Alternative (Lean.MonadCacheT α β m)
instance
Lean.MonadStateCacheT.instMonadHashMapCacheAdapterMonadStateCacheT
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
:
Lean.MonadHashMapCacheAdapter α β (Lean.MonadStateCacheT α β m)
instance
Lean.MonadStateCacheT.instMonadExceptOfMonadStateCacheT
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
(ε : Type u_1)
[MonadExceptOf ε m]
:
MonadExceptOf ε (Lean.MonadStateCacheT α β m)
instance
Lean.MonadStateCacheT.instMonadControlMonadStateCacheT
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
:
MonadControl m (Lean.MonadStateCacheT α β m)
instance
Lean.MonadStateCacheT.instMonadFinallyMonadStateCacheT
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
[MonadFinally m]
:
MonadFinally (Lean.MonadStateCacheT α β m)
instance
Lean.MonadStateCacheT.instMonadRefMonadStateCacheT
{α : Type}
{β : Type}
{m : Type → Type}
[BEq α]
[Hashable α]
[Monad m]
[Lean.MonadRef m]
:
Lean.MonadRef (Lean.MonadStateCacheT α β m)