Safe Haskell | None |
---|---|

Language | Haskell98 |

- data Cached m a
- runCached :: Cached m a -> m a
- cache :: (MonadFix m, MonadIO m) => m a -> Cached m a
- fromPure :: Monad m => a -> Cached m a
- don'tCache :: Monad m => m a -> Cached m a
- liftCached1 :: (MonadFix m, MonadIO m) => (a -> m b) -> Cached m a -> Cached m b
- liftCached2 :: (MonadFix m, MonadIO 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.

cache :: (MonadFix m, MonadIO m) => m a -> Cached m a Source

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 :: Monad m => m a -> Cached m a Source

Lift an action that is *not* cached, for instance because it is idempotent.