monad-memo-0.5.4: Memoization monad transformer

Copyright | (c) Eduard Sergeev 2013
License | BSD-style (see the file LICENSE)
Maintainer | eduard.sergeev@gmail.com
Stability | experimental
Portability | non-portable (multi-param classes, flexible instances)
Safe Haskell | None
Language | Haskell2010

Control.Monad.Trans.Memo.StateCache

Description

Generic StateCache - wrapper around `StateT`

Synopsis

- data StateCache c (m :: Type -> Type) a
- runStateCache :: StateCache s m a -> s -> m (a, s)
- container :: forall (m :: Type -> Type) c. Monad m => StateCache c m c
- setContainer :: forall (m :: Type -> Type) c. Monad m => c -> StateCache c m ()
- evalStateCache :: Monad m => StateCache c m a -> c -> m a

# Documentation

data StateCache c (m :: Type -> Type) a Source #

#### Instances

Instances details

MArray IOUArray e IO => MArray IOUArray e (StateCache c IO) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Methods

getBounds :: Ix i => IOUArray i e -> StateCache c IO (i, i) Source #

getNumElements :: Ix i => IOUArray i e -> StateCache c IO Int Source #

newArray :: Ix i => (i, i) -> e -> StateCache c IO (IOUArray i e) Source #

newArray_ :: Ix i => (i, i) -> StateCache c IO (IOUArray i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> StateCache c IO (IOUArray i e) Source #

unsafeRead :: Ix i => IOUArray i e -> Int -> StateCache c IO e Source #

unsafeWrite :: Ix i => IOUArray i e -> Int -> e -> StateCache c IO () Source #

MArray IOArray e (StateCache c IO) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Methods

getBounds :: Ix i => IOArray i e -> StateCache c IO (i, i) Source #

getNumElements :: Ix i => IOArray i e -> StateCache c IO Int Source #

newArray :: Ix i => (i, i) -> e -> StateCache c IO (IOArray i e) Source #

newArray_ :: Ix i => (i, i) -> StateCache c IO (IOArray i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> StateCache c IO (IOArray i e) Source #

unsafeRead :: Ix i => IOArray i e -> Int -> StateCache c IO e Source #

unsafeWrite :: Ix i => IOArray i e -> Int -> e -> StateCache c IO () 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 #
(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 #
(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 #
(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 #
MonadTrans (StateCache c) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods lift :: Monad m => m a -> StateCache c m a Source #
MArray (STUArray s) e (ST s) => MArray (STUArray s) e (StateCache c (ST s)) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Methods

getBounds :: Ix i => STUArray s i e -> StateCache c (ST s) (i, i) Source #

getNumElements :: Ix i => STUArray s i e -> StateCache c (ST s) Int Source #

newArray :: Ix i => (i, i) -> e -> StateCache c (ST s) (STUArray s i e) Source #

newArray_ :: Ix i => (i, i) -> StateCache c (ST s) (STUArray s i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> StateCache c (ST s) (STUArray s i e) Source #

unsafeRead :: Ix i => STUArray s i e -> Int -> StateCache c (ST s) e Source #

unsafeWrite :: Ix i => STUArray s i e -> Int -> e -> StateCache c (ST s) () Source #

MArray (STArray s) e (StateCache c (ST s)) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Methods

getBounds :: Ix i => STArray s i e -> StateCache c (ST s) (i, i) Source #

getNumElements :: Ix i => STArray s i e -> StateCache c (ST s) Int Source #

newArray :: Ix i => (i, i) -> e -> StateCache c (ST s) (STArray s i e) Source #

newArray_ :: Ix i => (i, i) -> StateCache c (ST s) (STArray s i e) Source #

unsafeNewArray_ :: Ix i => (i, i) -> StateCache c (ST s) (STArray s i e) Source #

unsafeRead :: Ix i => STArray s i e -> Int -> StateCache c (ST s) e Source #

unsafeWrite :: Ix i => STArray s i e -> Int -> e -> StateCache c (ST s) () Source #

MonadIO m => MonadIO (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods liftIO :: IO a -> StateCache c m a Source #
MonadPlus m => Alternative (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods empty :: StateCache c m a Source # (<|>) :: StateCache c m a -> StateCache c m a -> StateCache c m a Source # some :: StateCache c m a -> StateCache c m [a] Source # many :: StateCache c m a -> StateCache c m [a] Source #
Monad m => Applicative (StateCache c m) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Methods

pure :: a -> StateCache c m a Source #

(<*>) :: StateCache c m (a -> b) -> StateCache c m a -> StateCache c m b Source #

liftA2 :: (a -> b -> c0) -> StateCache c m a -> StateCache c m b -> StateCache c m c0 Source #

(*>) :: StateCache c m a -> StateCache c m b -> StateCache c m b Source #

(<*) :: StateCache c m a -> StateCache c m b -> StateCache c m a Source #

Functor m => Functor (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods fmap :: (a -> b) -> StateCache c m a -> StateCache c m b Source # (<$) :: a -> StateCache c m b -> StateCache c m a Source #
Monad m => Monad (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods (>>=) :: StateCache c m a -> (a -> StateCache c m b) -> StateCache c m b Source # (>>) :: StateCache c m a -> StateCache c m b -> StateCache c m b Source # return :: a -> StateCache c m a Source #
MonadPlus m => MonadPlus (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods mzero :: StateCache c m a Source # mplus :: StateCache c m a -> StateCache c m a -> StateCache c m a Source #
MonadFix m => MonadFix (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache Methods mfix :: (a -> StateCache c m a) -> StateCache c m a Source #
PrimMonad m => PrimMonad (StateCache c m) Source # |

Instance details

Defined in Control.Monad.Trans.Memo.StateCache

Associated Types

type PrimState (StateCache c m) |
Instance details Defined in Control.Monad.Trans.Memo.StateCache type PrimState (StateCache c m) = PrimState m

Methods

primitive :: (State# (PrimState (StateCache c m)) -> (# State# (PrimState (StateCache c m)), a #)) -> StateCache c m a Source #

type PrimState (StateCache c m) Source # |
Instance details Defined in Control.Monad.Trans.Memo.StateCache type PrimState (StateCache c m) = PrimState m

runStateCache :: StateCache s m a -> s -> m (a, s) Source #

container :: forall (m :: Type -> Type) c. Monad m => StateCache c m c Source #

Returns internal container

setContainer :: forall (m :: Type -> Type) c. Monad m => c -> StateCache c m () Source #

Assigns new value to internal container

evalStateCache :: Monad m => StateCache c m a -> c -> m a Source #

Evaluates computation discarding the resulting container