Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- zoom :: Monad m => LensLike' (Zooming m c) a b -> StateT b m c -> StateT a m c
- use :: Monad m => FoldLike b a a' b b' -> StateT a m b
- uses :: Monad m => FoldLike r a a' b b' -> (b -> r) -> StateT a m r
- (%=) :: Monad m => ASetter a a b b' -> (b -> b') -> StateT a m ()
- assign :: Monad m => ASetter a a b b' -> b' -> StateT a m ()
- (.=) :: Monad m => ASetter a a b b' -> b' -> StateT a m ()
- (%%=) :: Monad m => LensLike (Writer c) a a b b' -> (b -> (c, b')) -> StateT a m c
- (<~) :: Monad m => ASetter a a b b' -> StateT a m b' -> StateT a m ()
- (+=) :: (Monad m, Num b) => ASetter' a b -> b -> StateT a m ()
- (-=) :: (Monad m, Num b) => ASetter' a b -> b -> StateT a m ()
- (*=) :: (Monad m, Num b) => ASetter' a b -> b -> StateT a m ()
- (//=) :: (Monad m, Fractional b) => ASetter' a b -> b -> StateT a m ()
- (&&=) :: Monad m => ASetter' a Bool -> Bool -> StateT a m ()
- (||=) :: Monad m => ASetter' a Bool -> Bool -> StateT a m ()
- (<>=) :: (Monoid o, Monad m) => ASetter' a o -> o -> StateT a m ()
- data Zooming m c a
- type LensLike f a a' b b' = (b -> f b') -> a -> f a'
- type LensLike' f a b = (b -> f b) -> a -> f a
- type FoldLike r a a' b b' = LensLike (Constant r) a a' b b'
- data Constant k a b :: forall k. * -> k -> *
- type ASetter a a' b b' = LensLike Identity a a' b b'
- type ASetter' a b = LensLike' Identity a b
- data Identity a :: * -> *
- data StateT s m a :: * -> (* -> *) -> * -> *
- type Writer w = WriterT w Identity
- class Monoid a
Documentation
zoom :: Monad m => LensLike' (Zooming m c) a b -> StateT b m c -> StateT a m c Source #
zoom :: Monad m => Lens' a b -> StateT b m c -> StateT a 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 :: (Monoid c, Monad m) => Traversal' a b -> StateT b m c -> StateT a m c
Run the "subroutine" on each element of the traversal in turn and mconcat
all the results together.
zoom :: Monad m => Traversal' a b -> StateT b m () -> StateT a m ()
Run the "subroutine" on each element the traversal in turn.
use :: Monad m => FoldLike b a a' b b' -> StateT a m b Source #
use :: Monad m => Getter a a' b b' -> StateT a m b
Retrieve a field of the state
use :: (Monoid b, Monad m) => Fold a a' b b' -> StateT a m b
Retrieve a monoidal summary of all the referenced fields from the state
uses :: Monad m => FoldLike r a a' b b' -> (b -> r) -> StateT a m r Source #
uses :: (Monoid r, Monad m) => Fold a a' b b' -> (b -> r) -> StateT a m r
Retrieve all the referenced fields from the state and foldMap the results together with f :: b -> r
.
uses :: Monad m => Getter a a' b b' -> (b -> r) -> StateT a m r
Retrieve a field of the state and pass it through the function f :: b -> r
.
uses l f = f <$> use l
(%=) :: Monad m => ASetter a a b b' -> (b -> b') -> StateT a m () infix 4 Source #
Modify a field of the state.
(.=) :: Monad m => ASetter a a b b' -> b' -> StateT a m () infix 4 Source #
Set a field of the state.
(%%=) :: Monad m => LensLike (Writer c) a a b b' -> (b -> (c, b')) -> StateT a m c infix 4 Source #
(%%=) :: Monad m => Lens a a b b' -> (b -> (c, b')) -> StateT a m c
Modify a field of the state while returning another value.
(%%=) :: (Monad m, Monoid c) => Traversal a a b b' -> (b -> (c, b')) -> StateT a m c
Modify each field of the state and return the mconcat
of the other values.
(<~) :: Monad m => ASetter a a b b' -> StateT a m b' -> StateT a m () infixr 2 Source #
Set a field of the state using the result of executing a stateful command.
Compound Assignments
(<>=) :: (Monoid o, Monad m) => ASetter' a o -> o -> StateT a m () infixr 4 Source #
Monoidally append a value to all referenced fields of the state.
Types
Re-exports
data Constant k a b :: forall k. * -> k -> * #
Constant functor.
Eq2 (Constant *) | |
Ord2 (Constant *) | |
Read2 (Constant *) | |
Show2 (Constant *) | |
Bifunctor (Constant *) | |
Functor (Constant * a) | |
Monoid a => Applicative (Constant * a) | |
Foldable (Constant * a) | |
Traversable (Constant * a) | |
Eq a => Eq1 (Constant * a) | |
Ord a => Ord1 (Constant * a) | |
Read a => Read1 (Constant * a) | |
Show a => Show1 (Constant * a) | |
Phantom (Constant * a) Source # | |
Eq a => Eq (Constant k a b) | |
Ord a => Ord (Constant k a b) | |
Read a => Read (Constant k a b) | |
Show a => Show (Constant k a b) | |
Monoid a => Monoid (Constant k a b) | |
Identity functor and monad. (a non-strict monad)
Since: 4.8.0.0
data StateT s m 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.
MonadTrans (StateT s) | |
Monad m => Monad (StateT s m) | |
Functor m => Functor (StateT s m) | |
MonadFix m => MonadFix (StateT s m) | |
MonadFail m => MonadFail (StateT s m) | |
(Functor m, Monad m) => Applicative (StateT s m) | |
MonadIO m => MonadIO (StateT s m) | |
(Functor m, MonadPlus m) => Alternative (StateT s m) | |
MonadPlus m => MonadPlus (StateT s m) | |
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
mappend mempty x = x
mappend x mempty = x
mappend x (mappend y z) = mappend (mappend x y) z
mconcat =
foldr
mappend mempty
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
Monoid Ordering | |
Monoid () | |
Monoid All | |
Monoid Any | |
Monoid IntSet | |
Monoid [a] | |
Monoid a => Monoid (Maybe a) | Lift a semigroup into |
Monoid a => Monoid (IO a) | |
Ord a => Monoid (Max a) | |
Ord a => Monoid (Min a) | |
Monoid a => Monoid (Identity a) | |
(Ord a, Bounded a) => Monoid (Min a) | |
(Ord a, Bounded a) => Monoid (Max a) | |
Monoid m => Monoid (WrappedMonoid m) | |
Semigroup a => Monoid (Option a) | |
Monoid a => Monoid (Dual a) | |
Monoid (Endo a) | |
Num a => Monoid (Sum a) | |
Num a => Monoid (Product a) | |
Monoid (First a) | |
Monoid (Last a) | |
Monoid (IntMap a) | |
Ord a => Monoid (Set a) | |
Monoid b => Monoid (a -> b) | |
(Monoid a, Monoid b) => Monoid (a, b) | |
Monoid (Proxy k s) | |
Ord k => Monoid (Map k v) | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | |
Monoid a => Monoid (Const k a b) | |
Alternative f => Monoid (Alt * f a) | |
Monoid a => Monoid (Constant k a b) | |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | |