Safe Haskell | None |
---|---|
Language | Haskell2010 |
An experimental idea to see if we can whole-sale cache the results of certain effect computations, when we can be confident that their repeated invocation should result in the same outcome. The idea is that a first interpretation of the effect stack (e.g. during a validation or dry run) can produce this memoization cache and repeated interpretations of the same effect during the same program session can just lookup results from th cache.
A good example is parsing of SQL files from disk. We'd want to do it once and have much faster resolution on repeat runs.
Documentation
newtype ResultCache (a :: EffectRow) #
Instances
Semigroup (ResultCache a) # | |
Defined in Polysemy.Memoize (<>) :: ResultCache a -> ResultCache a -> ResultCache a # sconcat :: NonEmpty (ResultCache a) -> ResultCache a # stimes :: Integral b => b -> ResultCache a -> ResultCache a # | |
Monoid (ResultCache a) # | |
Defined in Polysemy.Memoize mempty :: ResultCache a # mappend :: ResultCache a -> ResultCache a -> ResultCache a # mconcat :: [ResultCache a] -> ResultCache a # | |
Default (ResultCache a) # | |
Defined in Polysemy.Memoize def :: ResultCache a # |
insertCache :: forall eff m a c. (CachableEffect eff c, Ord (eff m a), Eq (eff m a)) => eff m a -> a -> Map TypeRep SubCache -> Map TypeRep SubCache #
insertCache' :: (CachableEffect eff c, Ord (eff m a), Eq (eff m a), Member (AtomicState (ResultCache ce)) r, Member eff ce) => eff m a -> a -> Sem r () #
lookupCache :: forall eff m a c. (CachableEffect eff c, Ord (eff m a), Eq (eff m a)) => eff m a -> Map TypeRep SubCache -> Maybe a #
lookupCache' :: (CachableEffect eff c, Ord (eff m a), Eq (eff m a), Member (AtomicState (ResultCache ce)) r, Member eff ce) => eff m a -> Sem r (Maybe a) #
class Typeable (Proxy b) => CachableEffect a b | a -> b where #
Nothing
Instances
CachableEffect (SqlRender :: k -> Type -> Type) SqlRenderCacheKey # | |
Defined in Napkin.Run.Effects.Languages.SqlRender | |
CachableEffect (SqlParse :: k -> Type -> Type) SqlParseCacheKey # | |
Defined in Napkin.Run.Effects.Languages.SqlParse | |
CachableEffect (LocalFile :: k -> Type -> Type) LocalFileCacheKey # | |
Defined in Napkin.Run.Effects.Languages.LocalFile | |
CachableEffect (Example :: k -> Type -> Type) ExampleCachableEffect # | |
Defined in Polysemy.Memoize.Example |
cacheEffect :: forall (e :: Effect) r rInitial m a c ce. (Eq (e m a), Ord (e m a), Member e r, Member (AtomicState (ResultCache ce)) r, CachableEffect e c, m ~ Sem rInitial, Coercible (e (Sem rInitial) a) (e (Sem r) a), Member e ce) => e (Sem rInitial) a -> Tactical e (Sem rInitial) r a #