Safe Haskell | None |
---|
- class (Monad m, MonadFix m) => HasCache m where
- data Cached m a
- runCached :: Cached m a -> m a
- cache :: HasCache m => m a -> Cached m a
- fromPure :: HasCache m => a -> Cached m a
- don'tCache :: HasCache m => m a -> Cached m a
- liftCached1 :: HasCache m => (a -> m b) -> Cached m a -> Cached m b
- liftCached2 :: HasCache m => (a -> b -> m c) -> Cached m a -> Cached m b -> Cached m c
Documentation
Utility for executing monadic actions once and then retrieving values from a cache.
Very useful for observable sharing.
class (Monad m, MonadFix m) => HasCache m whereSource
Type class for monads that have a lazy Vault
that can be used as a cache.
The cache has to be lazy in the values in order to be useful for recursion.
cache :: HasCache m => m a -> Cached m aSource
An action whose result will be cached. Executing the action the first time in the monad will execute the side effects. From then on, only the generated value will be returned.
don'tCache :: HasCache m => m a -> Cached m aSource
Lift an action that is not chached, for instance because it is idempotent.
liftCached1 :: HasCache m => (a -> m b) -> Cached m a -> Cached m bSource