rio-0.1.18.0: A standard library for Haskell

Safe Haskell | Safe
Language | Haskell2010

RIO.State

Description

Provides reexports of `MonadState` and related helpers.

Since: 0.1.4.0

# Documentation

class Monad m => MonadState s (m :: Type -> Type) | m -> s where #

Minimal complete definition

state | get, put

Methods

get :: m s #

put :: s -> m () #

state :: (s -> (a, s)) -> m a #

#### Instances

Instances details

HasStateRef s env => MonadState s (RIO env) Source # |
Instance details Defined in RIO.Prelude.RIO Methods get :: RIO env s # put :: s -> RIO env () # state :: (s -> (a, s)) -> RIO env a #
MonadState s m => MonadState s (MaybeT m) |
Instance details Defined in Control.Monad.State.Class Methods get :: MaybeT m s # put :: s -> MaybeT m () # state :: (s -> (a, s)) -> MaybeT m a #
MonadState s m => MonadState s (ListT m) |
Instance details Defined in Control.Monad.State.Class Methods get :: ListT m s # put :: s -> ListT m () # state :: (s -> (a, s)) -> ListT m a #
(Monoid w, MonadState s m) => MonadState s (WriterT w m) |
Instance details Defined in Control.Monad.State.Class Methods get :: WriterT w m s # put :: s -> WriterT w m () # state :: (s -> (a, s)) -> WriterT w m a #
(Monoid w, MonadState s m) => MonadState s (WriterT w m) |
Instance details Defined in Control.Monad.State.Class Methods get :: WriterT w m s # put :: s -> WriterT w m () # state :: (s -> (a, s)) -> WriterT w m a #
Monad m => MonadState s (StateT s m) |
Instance details Defined in Control.Monad.State.Class Methods get :: StateT s m s # put :: s -> StateT s m () # state :: (s -> (a, s)) -> StateT s m a #
Monad m => MonadState s (StateT s m) |
Instance details Defined in Control.Monad.State.Class Methods get :: StateT s m s # put :: s -> StateT s m () # state :: (s -> (a, s)) -> StateT s m a #
MonadState s m => MonadState s (ReaderT r m) |
Instance details Defined in Control.Monad.State.Class Methods get :: ReaderT r m s # put :: s -> ReaderT r m () # state :: (s -> (a, s)) -> ReaderT r m a #
MonadState s m => MonadState s (IdentityT m) |
Instance details Defined in Control.Monad.State.Class Methods get :: IdentityT m s # put :: s -> IdentityT m () # state :: (s -> (a, s)) -> IdentityT m a #
MonadState s m => MonadState s (ExceptT e m) |
Instance details Defined in Control.Monad.State.Class Methods get :: ExceptT e m s # put :: s -> ExceptT e m () # state :: (s -> (a, s)) -> ExceptT e m a #
(Error e, MonadState s m) => MonadState s (ErrorT e m) |
Instance details Defined in Control.Monad.State.Class Methods get :: ErrorT e m s # put :: s -> ErrorT e m () # state :: (s -> (a, s)) -> ErrorT e m a #
MonadState s m => MonadState s (ContT r m) |
Instance details Defined in Control.Monad.State.Class Methods get :: ContT r m s # put :: s -> ContT r m () # state :: (s -> (a, s)) -> ContT r m a #
(Monad m, Monoid w) => MonadState s (RWST r w s m) |
Instance details Defined in Control.Monad.State.Class Methods get :: RWST r w s m s # put :: s -> RWST r w s m () # state :: (s -> (a, s)) -> RWST r w s m a #
(Monad m, Monoid w) => MonadState s (RWST r w s m) |
Instance details Defined in Control.Monad.State.Class Methods get :: RWST r w s m s # put :: s -> RWST r w s m () # state :: (s -> (a, s)) -> RWST r w s m a #

gets :: MonadState s m => (s -> a) -> m a #

modify :: MonadState s m => (s -> s) -> m () #

modify' :: MonadState s m => (s -> s) -> m () #

type State s = StateT s Identity #

runState :: State s a -> s -> (a, s) #

evalState :: State s a -> s -> a #

execState :: State s a -> s -> s #

mapState :: ((a, s) -> (b, s)) -> State s a -> State s b #

withState :: (s -> s) -> State s a -> State s a #

newtype StateT s (m :: Type -> Type) a #

Constructors

StateT |

Fields

- runStateT :: s -> m (a, s)

#### Instances

Instances details

MonadReader r m => MonadReader r (StateT s m) |
Instance details Defined in Control.Monad.Reader.Class Methods ask :: StateT s m r # local :: (r -> r) -> StateT s m a -> StateT s m a # reader :: (r -> a) -> StateT s m a
Monad m => MonadState s (StateT s m) |
Instance details Defined in Control.Monad.State.Class Methods get :: StateT s m s # put :: s -> StateT s m () # state :: (s -> (a, s)) -> StateT s m a #
MonadWriter w m => MonadWriter w (StateT s m) |
Instance details Defined in Control.Monad.Writer.Class Methods writer :: (a, w) -> StateT s m a # tell :: w -> StateT s m () # listen :: StateT s m a -> StateT s m (a, w) # pass :: StateT s m (a, w -> w) -> StateT s m a #
MonadTrans (StateT s) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods lift :: Monad m => m a -> StateT s m a #
Monad m => Monad (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods (>>=) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b # (>>) :: StateT s m a -> StateT s m b -> StateT s m b # return :: a -> StateT s m a #
Functor m => Functor (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods fmap :: (a -> b) -> StateT s m a -> StateT s m b # (<$) :: a -> StateT s m b -> StateT s m a #
MonadFix m => MonadFix (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods mfix :: (a -> StateT s m a) -> StateT s m a
MonadFail m => MonadFail (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods fail :: String -> StateT s m a #
(Functor m, Monad m) => Applicative (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods pure :: a -> StateT s m a # (<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b # liftA2 :: (a -> b -> c) -> StateT s m a -> StateT s m b -> StateT s m c # (*>) :: StateT s m a -> StateT s m b -> StateT s m b # (<*) :: StateT s m a -> StateT s m b -> StateT s m a #
MonadThrow m => MonadThrow (StateT s m) |
Instance details Defined in Control.Monad.Catch Methods throwM :: Exception e => e -> StateT s m a Source #
MonadCatch m => MonadCatch (StateT s m) |
Instance details Defined in Control.Monad.Catch Methods catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a Source #
MonadMask m => MonadMask (StateT s m) |
Instance details Defined in Control.Monad.Catch Methods mask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # uninterruptibleMask :: ((forall a. StateT s m a -> StateT s m a) -> StateT s m b) -> StateT s m b Source # generalBracket :: StateT s m a -> (a -> ExitCase b -> StateT s m c) -> (a -> StateT s m b) -> StateT s m (b, c) Source #
PrimMonad m => PrimMonad (StateT s m) |
Instance details Defined in Control.Monad.Primitive Associated Types type PrimState (StateT s m) Source # Methods primitive :: (State# (PrimState (StateT s m)) -> (# State# (PrimState (StateT s m)), a #)) -> StateT s m a Source #
MonadIO m => MonadIO (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods liftIO :: IO a -> StateT s m a #
(Functor m, MonadPlus m) => Alternative (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods empty :: StateT s m a (<|>) :: StateT s m a -> StateT s m a -> StateT s m a # some :: StateT s m a -> StateT s m [a] # many :: StateT s m a -> StateT s m [a] #
MonadPlus m => MonadPlus (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods mzero :: StateT s m a # mplus :: StateT s m a -> StateT s m a -> StateT s m a #
Contravariant m => Contravariant (StateT s m) |
Instance details Defined in Control.Monad.Trans.State.Lazy Methods contramap :: (a -> b) -> StateT s m b -> StateT s m a (>$) :: b -> StateT s m b -> StateT s m a
Monad z => Zoom (StateT s z) (StateT t z) s t |
Instance details Defined in Lens.Micro.Mtl.Internal Methods zoom :: LensLike' (Zoomed (StateT s z) c) t s -> StateT s z c -> StateT t z c Source #
type Zoomed (StateT s z) |
Instance details Defined in Lens.Micro.Mtl.Internal type Zoomed (StateT s z) = Focusing z
type PrimState (StateT s m) |
Instance details Defined in Control.Monad.Primitive type PrimState (StateT s m) = PrimState m

evalStateT :: Monad m => StateT s m a -> s -> m a #

execStateT :: Monad m => StateT s m a -> s -> m s #

mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b #

withStateT :: forall s (m :: Type -> Type) a. (s -> s) -> StateT s m a -> StateT s m a #