monad-memo-0.5.1: Memoization monad transformer

Copyright(c) Eduard Sergeev 2011
LicenseBSD-style (see the file LICENSE)
Maintainereduard.sergeev@gmail.com
Stabilityexperimental
Portabilitynon-portable (multi-param classes, functional dependencies)
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Memo.Class

Description

Computation type:
Interface for monadic computations which can be memoized.
Synopsis

Documentation

class Monad m => MonadCache k v m | m -> k, m -> v where Source #

Interface for memoization cache Is necessary since memoization mechanism from one transformer can use a cache from other (further down the stack)

Minimal complete definition

lookup, add

Methods

lookup :: k -> m (Maybe v) Source #

add :: k -> v -> m () Source #

Instances
(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadCache Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector.Unsafe

Methods

lookup :: Int -> Cache c s e m (Maybe v) Source #

add :: Int -> v -> Cache c s e m () Source #

(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadCache Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector.Expandable

Methods

lookup :: Int -> Cache c s e m (Maybe v) Source #

add :: Int -> v -> Cache c s e m () Source #

(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadCache Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector

Methods

lookup :: Int -> Cache c s e m (Maybe v) Source #

add :: Int -> v -> Cache c s e m () Source #

(Monad m, MapLike c k v) => MonadCache k v (MemoStateT c k v m) Source # 
Instance details

Defined in Control.Monad.Trans.Memo.State

Methods

lookup :: k -> MemoStateT c k v m (Maybe v) Source #

add :: k -> v -> MemoStateT c k v m () Source #

(Monad m, Ix k, MaybeLike e v, MArray c e m) => MonadCache k v (Cache c k e m) Source # 
Instance details

Defined in Control.Monad.Memo.Array

Methods

lookup :: k -> Cache c k e m (Maybe v) Source #

add :: k -> v -> Cache c k e m () Source #

class Monad m => MonadMemo k v m | m -> k, m -> v where Source #

Memoization interface

Minimal complete definition

memo

Methods

memo :: (k -> m v) -> k -> m v Source #

Instances
MonadCache k (Maybe v) m => MonadMemo k v (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> MaybeT m v) -> k -> MaybeT m v Source #

MonadCache (s, k) (v, s) m => MonadMemo k v (StateT s m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> StateT s m v) -> k -> StateT s m v Source #

MonadCache (s, k) (v, s) m => MonadMemo k v (StateT s m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> StateT s m v) -> k -> StateT s m v Source #

(Monoid w, MonadCache k (v, w) m) => MonadMemo k v (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> WriterT w m v) -> k -> WriterT w m v Source #

(Monoid w, MonadCache k (v, w) m) => MonadMemo k v (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> WriterT w m v) -> k -> WriterT w m v Source #

MonadCache k (Either e v) m => MonadMemo k v (ExceptT e m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> ExceptT e m v) -> k -> ExceptT e m v Source #

MonadCache k v m => MonadMemo k v (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> IdentityT m v) -> k -> IdentityT m v Source #

MonadCache (r, k) v m => MonadMemo k v (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> ReaderT r m v) -> k -> ReaderT r m v Source #

MonadCache k v m => MonadMemo k v (ContT r m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> ContT r m v) -> k -> ContT r m v Source #

(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadMemo Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector.Unsafe

Methods

memo :: (Int -> Cache c s e m v) -> Int -> Cache c s e m v Source #

(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadMemo Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector.Expandable

Methods

memo :: (Int -> Cache c s e m v) -> Int -> Cache c s e m v Source #

(PrimMonad m, PrimState m ~ s, MaybeLike e v, MVector c e) => MonadMemo Int v (Cache c s e m) Source # 
Instance details

Defined in Control.Monad.Memo.Vector

Methods

memo :: (Int -> Cache c s e m v) -> Int -> Cache c s e m v Source #

(Monoid w, MonadCache (r, s, k) (v, s, w) m) => MonadMemo k v (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> RWST r w s m v) -> k -> RWST r w s m v Source #

(Monoid w, MonadCache (r, s, k) (v, s, w) m) => MonadMemo k v (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Memo.Class

Methods

memo :: (k -> RWST r w s m v) -> k -> RWST r w s m v Source #

(Monad m, MapLike c k v) => MonadMemo k v (MemoStateT c k v m) Source # 
Instance details

Defined in Control.Monad.Trans.Memo.State

Methods

memo :: (k -> MemoStateT c k v m v) -> k -> MemoStateT c k v m v Source #

(Monad m, Ix k, MaybeLike e v, MArray c e m) => MonadMemo k v (Cache c k e m) Source # 
Instance details

Defined in Control.Monad.Memo.Array

Methods

memo :: (k -> Cache c k e m v) -> k -> Cache c k e m v Source #

for2 :: (((k1, k2) -> mv) -> (k1, k2) -> mv) -> (k1 -> k2 -> mv) -> k1 -> k2 -> mv Source #

Adapter for memoization of two-argument function

for3 :: (((k1, k2, k3) -> mv) -> (k1, k2, k3) -> mv) -> (k1 -> k2 -> k3 -> mv) -> k1 -> k2 -> k3 -> mv Source #

Adapter for memoization of three-argument function

for4 :: (((k1, k2, k3, k4) -> mv) -> (k1, k2, k3, k4) -> mv) -> (k1 -> k2 -> k3 -> k4 -> mv) -> k1 -> k2 -> k3 -> k4 -> mv Source #

Adapter for memoization of four-argument function

memoln :: (MonadCache k2 v m1, Monad m1, Monad m2) => (forall a. m1 a -> m2 a) -> (k1 -> k2) -> (k1 -> m2 v) -> k1 -> m2 v Source #

Memoization for the current transformer in stack using a cache from an arbitrary transformer down the stack

memol0 :: (MonadCache k v m, Monad m) => (k -> m v) -> k -> m v Source #

Uses current monad's memoization cache

memol1 :: (MonadTrans t1, MonadCache k v m, Monad (t1 m)) => (k -> t1 m v) -> k -> t1 m v Source #

Uses the 1st transformer in stack for memoization cache

memol2 :: (MonadTrans t1, MonadTrans t2, MonadCache k v m, Monad (t2 m), Monad (t1 (t2 m))) => (k -> t1 (t2 m) v) -> k -> t1 (t2 m) v Source #

Uses the 2nd transformer in stack for memoization cache

memol3 :: (MonadTrans t1, MonadTrans t2, MonadTrans t3, MonadCache k v m, Monad (t3 m), Monad (t2 (t3 m)), Monad (t1 (t2 (t3 m)))) => (k -> t1 (t2 (t3 m)) v) -> k -> t1 (t2 (t3 m)) v Source #

Uses the 3rd transformer in stack for memoization cache

memol4 :: (MonadTrans t1, MonadTrans t2, MonadTrans t3, MonadTrans t4, MonadCache k v m, Monad (t4 m), Monad (t3 (t4 m)), Monad (t2 (t3 (t4 m))), Monad (t1 (t2 (t3 (t4 m))))) => (k -> t1 (t2 (t3 (t4 m))) v) -> k -> t1 (t2 (t3 (t4 m))) v Source #

Uses the 4th transformer in stack for memoization cache