{-# LANGUAGE NoImplicitPrelude, GeneralizedNewtypeDeriving #-}
module Control.Monad.Trans.Memo.StateCache
(
StateCache,
runStateCache,
container,
setContainer,
evalStateCache
) where
import Data.Function
import Control.Applicative
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Fix
import Control.Monad.Trans.Class
import Control.Monad.Trans.State.Strict
newtype StateCache c m a = StateCache { toStateT :: StateT c m a }
deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadFix, MonadTrans, MonadIO)
{-# INLINE runStateCache #-}
runStateCache = runStateT . toStateT
evalStateCache :: Monad m => StateCache c m a -> c -> m a
{-# INLINE evalStateCache #-}
evalStateCache = evalStateT . toStateT
container :: Monad m => StateCache c m c
{-# INLINE container #-}
container = StateCache get
setContainer :: Monad m => c -> StateCache c m ()
{-# INLINE setContainer #-}
setContainer = StateCache . put