foundation-0.0.17: Alternative prelude with batteries and no dependencies

Safe Haskell | None
Language | Haskell2010

Foundation.Monad.State

Contents

- MonadState
- StateT

Synopsis

- class Monad m => MonadState m where
  - type State m
- get :: MonadState m => m (State m)
- put :: MonadState m => State m -> m ()
- data StateT s m a
- runStateT :: StateT s m a -> s -> m (a, s)

# MonadState

class Monad m => MonadState m where Source #

Minimal complete definition

withState

Associated Types

type State m Source #

Methods

withState :: (State m -> (a, State m)) -> m a Source #

Instances

MonadState Check Source # |
Associated Types type State (Check :: * -> *) :: * Source # Methods withState :: (State Check -> (a, State Check)) -> Check a Source #
(Functor m, Monad m) => MonadState (StateT s m) Source # |
Associated Types type State (StateT s m :: * -> *) :: * Source # Methods withState :: (State (StateT s m) -> (a, State (StateT s m))) -> StateT s m a Source #

get :: MonadState m => m (State m) Source #

put :: MonadState m => State m -> m () Source #

# StateT

data StateT s m a Source #

State Transformer

Instances

MonadTrans (StateT s) Source # |
Methods lift :: Monad m => m a -> StateT s m a Source #
(Functor m, Monad m) => Monad (StateT s m) Source # |
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 # fail :: String -> StateT s m a #
Functor m => Functor (StateT s m) Source # |
Methods fmap :: (a -> b) -> StateT s m a -> StateT s m b # (<$) :: a -> StateT s m b -> StateT s m a #
(Applicative m, Monad m) => Applicative (StateT s m) Source # |
Methods pure :: a -> StateT s m a # (<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b # (*>) :: StateT s m a -> StateT s m b -> StateT s m b # (<*) :: StateT s m a -> StateT s m b -> StateT s m a #
(Functor m, MonadIO m) => MonadIO (StateT s m) Source # |
Methods liftIO :: IO a -> StateT s m a #
(Functor m, MonadFailure m) => MonadFailure (StateT s m) Source # |
Associated Types type Failure (StateT s m :: * -> *) :: * # Methods mFail :: Failure (StateT s m) -> StateT s m () #
(Functor m, MonadCatch m) => MonadCatch (StateT s m) Source # |
Methods catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a Source #
(Functor m, MonadThrow m) => MonadThrow (StateT s m) Source # |
Methods throw :: Exception e => e -> StateT s m a Source #
(Functor m, Monad m) => MonadState (StateT s m) Source # |
Associated Types type State (StateT s m :: * -> *) :: * Source # Methods withState :: (State (StateT s m) -> (a, State (StateT s m))) -> StateT s m a Source #
type Failure (StateT s m) Source # |
type Failure (StateT s m) = Failure m
type State (StateT s m) Source # |
type State (StateT s m) = s

runStateT :: StateT s m a -> s -> m (a, s) Source #