foundation-0.0.30: Alternative prelude with batteries and no dependencies

Safe Haskell | None
Language | Haskell2010

Foundation.Monad.State

Contents

- MonadState
- StateT

Synopsis

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

# MonadState

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

Associated Types

type State (m :: Type -> Type) #

Methods

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

#### Instances

Instances details

MonadState Check # |
Instance details Defined in Foundation.Check.Types Associated Types
type State Check |
Instance details Defined in Foundation.Check.Types type State Check
Methods withState :: (State Check -> (a, State Check)) -> Check a #
(Functor m, Monad m) => MonadState (StateT s m) # |
Instance details Defined in Foundation.Monad.State Associated Types
type State (StateT s m) |
Instance details Defined in Foundation.Monad.State type State (StateT s m) = s
Methods withState :: (State (StateT s m) -> (a, State (StateT s m))) -> StateT s m a #

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

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

# StateT

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

State Transformer

#### Instances

Instances details

MonadTrans (StateT s) # |
Instance details Defined in Foundation.Monad.State Methods lift :: Monad m => m a -> StateT s m a #
(Functor m, MonadIO m) => MonadIO (StateT s m) # |
Instance details Defined in Foundation.Monad.State Methods liftIO :: IO a -> StateT s m a #
(Functor m, MonadFailure m) => MonadFailure (StateT s m) # |
Instance details Defined in Foundation.Monad.State Associated Types
type Failure (StateT s m) |
Instance details Defined in Foundation.Monad.State type Failure (StateT s m) = Failure m
Methods mFail :: Failure (StateT s m) -> StateT s m () #
(Functor m, MonadCatch m) => MonadCatch (StateT s m) # |
Instance details Defined in Foundation.Monad.State Methods catch :: Exception e => StateT s m a -> (e -> StateT s m a) -> StateT s m a #
(Functor m, MonadThrow m) => MonadThrow (StateT s m) # |
Instance details Defined in Foundation.Monad.State Methods throw :: Exception e => e -> StateT s m a #
(Functor m, Monad m) => MonadState (StateT s m) # |
Instance details Defined in Foundation.Monad.State Associated Types
type State (StateT s m) |
Instance details Defined in Foundation.Monad.State type State (StateT s m) = s
Methods withState :: (State (StateT s m) -> (a, State (StateT s m))) -> StateT s m a #
(Applicative m, Monad m) => Applicative (StateT s m) # |
Instance details Defined in Foundation.Monad.State 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 #
Functor m => Functor (StateT s m) # |
Instance details Defined in Foundation.Monad.State Methods fmap :: (a -> b) -> StateT s m a -> StateT s m b # (<$) :: a -> StateT s m b -> StateT s m a #
(Functor m, Monad m) => Monad (StateT s m) # |
Instance details Defined in Foundation.Monad.State 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, MonadFix m) => MonadFix (StateT s m) # |
Instance details Defined in Foundation.Monad.State Methods mfix :: (a -> StateT s m a) -> StateT s m a #
type Failure (StateT s m) # |
Instance details Defined in Foundation.Monad.State type Failure (StateT s m) = Failure m
type State (StateT s m) # |
Instance details Defined in Foundation.Monad.State type State (StateT s m) = s

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