Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- zoom :: forall (m :: Type -> Type) c s a. Monad m => LensLike' (Zooming m c) s a -> StateT a m c -> StateT s m c
- use :: MonadState s m => FoldLike a s t a b -> m a
- uses :: MonadState s m => FoldLike r s t a b -> (a -> r) -> m r
- (%=) :: MonadState s m => Setter s s a b -> (a -> b) -> m ()
- assign :: MonadState s m => Setter s s a b -> b -> m ()
- (.=) :: MonadState s m => Setter s s a b -> b -> m ()
- (%%=) :: MonadState s m => LensLike (Writer c) s s a b -> (a -> (c, b)) -> m c
- (<~) :: MonadState s m => Setter s s a b -> m b -> m ()
- (+=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (-=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (*=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (//=) :: (MonadState s m, Fractional a) => Setter' s a -> a -> m ()
- (&&=) :: MonadState s m => Setter' s Bool -> Bool -> m ()
- (||=) :: MonadState s m => Setter' s Bool -> Bool -> m ()
- (<>=) :: (MonadState s m, Monoid a) => Setter' s a -> a -> m ()
- (%!=) :: MonadState s m => Setter s s a b -> (a -> b) -> m ()
- (+!=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (-!=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (*!=) :: (MonadState s m, Num a) => Setter' s a -> a -> m ()
- (//!=) :: (MonadState s m, Fractional a) => Setter' s a -> a -> m ()
- (&&!=) :: MonadState s m => Setter' s Bool -> Bool -> m ()
- (||!=) :: MonadState s m => Setter' s Bool -> Bool -> m ()
- (<>!=) :: (MonadState s m, Monoid a) => Setter' s a -> a -> m ()
- data Zooming (m :: Type -> Type) c a
- type LensLike (f :: Type -> Type) s t a b = (a -> f b) -> s -> f t
- type LensLike' (f :: Type -> Type) s a = (a -> f a) -> s -> f s
- type FoldLike r s t a b = LensLike (Constant r :: Type -> Type) s t a b
- data Constant a (b :: k)
- type Setter s t a b = forall f. Identical f => LensLike f s t a b
- type Setter' s a = forall f. Identical f => LensLike' f s a
- class (Traversable f, Applicative f) => Identical (f :: Type -> Type)
- data StateT s (m :: Type -> Type) a
- class Monad m => MonadState s (m :: Type -> Type) | m -> s
- type Writer w = WriterT w Identity
Documentation
zoom :: forall (m :: Type -> Type) c s a. Monad m => LensLike' (Zooming m c) s a -> StateT a m c -> StateT s m c #
zoom :: Monad m => Lens' s a -> StateT a m c -> StateT s m c
Lift a stateful operation on a field to a stateful operation on the whole state. This is a good way to call a "subroutine" that only needs access to part of the state.
zoom :: (Monad m, Monoid c) => Traversal' s a -> StateT a m c -> StateT s m c
Run the "subroutine" on each element of the traversal in turn and mconcat
all the results together.
zoom :: Monad m => Traversal' s a -> StateT a m () -> StateT s m ()
Run the "subroutine" on each element the traversal in turn.
use :: MonadState s m => FoldLike a s t a b -> m a Source #
use :: MonadState s m => Getter s t a b -> m a
Retrieve a field of the state
use :: (MonadState s m, Monoid a) => Fold s t a b -> m a
Retrieve a monoidal summary of all the referenced fields from the state
uses :: MonadState s m => FoldLike r s t a b -> (a -> r) -> m r Source #
uses :: (MonadState s m, Monoid r) => Fold s t a b -> (a -> r) -> m r
Retrieve all the referenced fields from the state and foldMap the results together with f :: a -> r
.
uses :: MonadState s m => Getter s t a b -> (a -> r) -> m r
Retrieve a field of the state and pass it through the function f :: a -> r
.
uses l f = f <$> use l
(%=) :: MonadState s m => Setter s s a b -> (a -> b) -> m () infix 4 Source #
Modify a field of the state.
assign :: MonadState s m => Setter s s a b -> b -> m () Source #
Set a field of the state.
(.=) :: MonadState s m => Setter s s a b -> b -> m () infix 4 Source #
Set a field of the state.
(%%=) :: MonadState s m => LensLike (Writer c) s s a b -> (a -> (c, b)) -> m c infix 4 Source #
(%%=) :: MonadState s m => Lens s s a b -> (a -> (c, b)) -> m c
Modify a field of the state while returning another value.
(%%=) :: (MonadState s m, Monoid c) => Traversal s s a b -> (a -> (c, b)) -> m c
Modify each field of the state and return the mconcat
of the other values.
(<~) :: MonadState s m => Setter s s a b -> m b -> m () infixr 2 Source #
Set a field of the state using the result of executing a stateful command.
Compound Assignments
(//=) :: (MonadState s m, Fractional a) => Setter' s a -> a -> m () infixr 4 Source #
(<>=) :: (MonadState s m, Monoid a) => Setter' s a -> a -> m () infixr 4 Source #
Monoidally append a value to all referenced fields of the state.
Strict Assignments
(%!=) :: MonadState s m => Setter s s a b -> (a -> b) -> m () infix 4 Source #
Strictly modify a field of the state.
(//!=) :: (MonadState s m, Fractional a) => Setter' s a -> a -> m () infixr 4 Source #
Types
data Zooming (m :: Type -> Type) c a #
Instances
Monad m => Functor (Zooming m c) | |
(Monoid c, Monad m) => Applicative (Zooming m c) | |
Defined in Lens.Family.State.Zoom |
Re-exports
Constant functor.
Instances
data StateT s (m :: Type -> Type) a #
A state transformer monad parameterized by:
s
- The state.m
- The inner monad.
The return
function leaves the state unchanged, while >>=
uses
the final state of the first computation as the initial state of
the second.
Instances
Monad m => MonadState s (StateT s m) | |
MonadTrans (StateT s) | |
Defined in Control.Monad.Trans.State.Strict | |
Monad m => Monad (StateT s m) | |
Functor m => Functor (StateT s m) | |
MonadFix m => MonadFix (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
MonadFail m => MonadFail (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
Contravariant m => Contravariant (StateT s m) | |
MonadIO m => MonadIO (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
(Functor m, MonadPlus m) => Alternative (StateT s m) | |
MonadPlus m => MonadPlus (StateT s m) | |
class Monad m => MonadState s (m :: Type -> Type) | m -> s #
Minimal definition is either both of get
and put
or just state
Instances
MonadState s m => MonadState s (MaybeT m) | |
MonadState s m => MonadState s (ListT m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
Monad m => MonadState s (StateT s m) | |
Monad m => MonadState s (StateT s m) | |
MonadState s m => MonadState s (ReaderT r m) | |
MonadState s m => MonadState s (IdentityT m) | |
MonadState s m => MonadState s (ExceptT e m) | Since: mtl-2.2 |
(Error e, MonadState s m) => MonadState s (ErrorT e m) | |
MonadState s m => MonadState s (ContT r m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | |