Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class ArrowKleisli m arr => ArrowCache m arr | arr -> m where
- cache :: Cacheable a => arr a b -> arr a b
- newDependency :: arr a (Dependency a)
- dependOn :: Cacheable a => arr (Dependency a) a
- bindDepend :: arr (DependT m a) a
- class Monad m => MonadDepend m where
- dependOnM :: Cacheable a => Dependency a -> m a
- newtype DependT m a = DependT {}
Documentation
class ArrowKleisli m arr => ArrowCache m arr | arr -> m where Source #
cache :: Cacheable a => arr a b -> arr a b Source #
Adds equality-based caching to the given arrow. After each execution of the arrow, its input
and result values are cached. On the next execution, the new input value is compared via ==
to the previous input value. If they are the same, the previous result is returned without
re-executing the arrow. Otherwise, the old cached values are discarded, and the arrow is
re-executed to produce a new set of cached values.
Indescriminate use of cache
is likely to have little effect except to increase memory usage,
since the input and result of each execution must be retained in memory. Avoid using cache
around arrows with large input or output that is likely to change often unless profiling
indicates it is computationally expensive enough to be worth the memory overhead.
Note that only direct inputs and outputs of the given arrow are cached. If an arrow provides access to values through a side-channel, they will not participate in caching.
newDependency :: arr a (Dependency a) Source #
Creates a new Dependency
, which allows fine-grained caching of composite values; see the
documentation for Dependency
for more details.
dependOn :: Cacheable a => arr (Dependency a) a Source #
Extract the value from a Dependency
, incurring a dependency on its entirety. To depend on
only a portion of the value, use selectD
or selectKeyD
before passing it to dependOn
.
bindDepend :: arr (DependT m a) a Source #
Run a monadic sub-computation with the ability to access dependencies; see MonadDepend
for
more details.
Instances
MonadUnique m => ArrowCache m (Rule m) Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
(Monoid w, ArrowCache m arr) => ArrowCache m (WriterA w arr) Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
(ArrowChoice arr, ArrowCache m arr) => ArrowCache m (ErrorA e arr) Source # | |
Defined in Hasura.Incremental.Internal.Cache |
class Monad m => MonadDepend m where Source #
A restricted, monadic variant of ArrowCache
that can only read dependencies, not create new
ones or add local caching. This serves as a limited adapter between arrow and monadic code.
dependOnM :: Cacheable a => Dependency a -> m a Source #
Instances
Monad m => MonadDepend (DependT m) Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
MonadDepend m => MonadDepend (ExceptT e m) Source # | |
Defined in Hasura.Incremental.Internal.Cache |
Instances
MonadTrans DependT Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
MonadError e m => MonadError e (DependT m) Source # | |
Defined in Hasura.Incremental.Internal.Cache throwError :: e -> DependT m a # catchError :: DependT m a -> (e -> DependT m a) -> DependT m a # | |
Monad m => Monad (DependT m) Source # | |
Functor m => Functor (DependT m) Source # | |
Monad m => Applicative (DependT m) Source # | |
Defined in Hasura.Incremental.Internal.Cache | |
Monad m => MonadDepend (DependT m) Source # | |
Defined in Hasura.Incremental.Internal.Cache |