Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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
Monoid (ResultCache a) # | |
Defined in Polysemy.Memoize mempty :: ResultCache a # mappend :: ResultCache a -> ResultCache a -> ResultCache a # mconcat :: [ResultCache a] -> ResultCache a # | |
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 # | |
Default (ResultCache a) # | |
Defined in Polysemy.Memoize def :: ResultCache a # |
insertCache :: forall eff m a c. (CachableEffect eff c, Ord (eff m a)) => eff m a -> a -> Map TypeRep SubCache -> Map TypeRep SubCache #
insertCache' :: (CachableEffect eff c, Ord (eff m a), Member (AtomicState (ResultCache ce)) r) => eff m a -> a -> Sem r () #
lookupCache :: forall eff m a c. (CachableEffect eff c, Ord (eff m a)) => eff m a -> Map TypeRep SubCache -> Maybe a #
lookupCache' :: (CachableEffect eff c, Ord (eff m a), Member (AtomicState (ResultCache ce)) r) => eff m a -> Sem r (Maybe a) #
class Typeable (Proxy b) => CachableEffect a b | a -> b where #
Nothing
Instances
CachableEffect (LoadQuery :: k -> Type -> Type) LoadQueryCacheKey # | |
Defined in Napkin.Run.Effects.Languages.LoadQuery | |
CachableEffect (SqlParse :: k -> Type -> Type) SqlParseCacheKey # | |
Defined in Napkin.Run.Effects.Languages.SqlParse | |
CachableEffect (SqlRender :: k -> Type -> Type) SqlRenderCacheKey # | |
Defined in Napkin.Run.Effects.Languages.SqlRender |
cacheEffect :: forall (e :: Effect) r rInitial m a c ce. (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 #