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

Safe HaskellNone
LanguageHaskell98

Reactive.Banana.Prim.Cached

Synopsis

Documentation

Utility for executing monadic actions once and then retrieving values from a cache.

Very useful for observable sharing.

data Cached m 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 :: 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 #