reactive-banana-1.3.2.0: Library for functional reactive programming (FRP).

Safe Haskell | None
Language | Haskell98

Reactive.Banana.Prim.High.Cached

Synopsis

- data Cached (m :: Type -> Type) a
- runCached :: Cached m a -> m a
- cache :: (MonadFix m, MonadIO m) => m a -> Cached m a
- fromPure :: forall (m :: Type -> Type) a. 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.

data Cached (m :: Type -> Type) a Source #

runCached :: Cached m a -> m a Source #

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.

fromPure :: forall (m :: Type -> Type) a. Monad m => a -> Cached m a Source #

Return a pure value. Doesn't make use of the cache.

don'tCache :: Monad m => m a -> Cached m a Source #

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

liftCached1 :: (MonadFix m, MonadIO m) => (a -> m b) -> Cached m a -> Cached m b Source #

liftCached2 :: (MonadFix m, MonadIO m) => (a -> b -> m c) -> Cached m a -> Cached m b -> Cached m c Source #