Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Synopsis
- zoom :: Monad m => LensLike' (Zooming m c) a b -> StateT b m c -> StateT a m c
- use :: MonadState a m => FoldLike b a a' b b' -> m b
- uses :: MonadState a m => FoldLike r a a' b b' -> (b -> r) -> m r
- (%=) :: MonadState a m => Setter a a b b' -> (b -> b') -> m ()
- assign :: MonadState a m => Setter a a b b' -> b' -> m ()
- (.=) :: MonadState a m => Setter a a b b' -> b' -> m ()
- (%%=) :: MonadState a m => LensLike (Writer c) a a b b' -> (b -> (c, b')) -> m c
- (<~) :: MonadState a m => Setter a a b b' -> m b' -> m ()
- (+=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (-=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (*=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (//=) :: (MonadState a m, Fractional b) => Setter' a b -> b -> m ()
- (&&=) :: MonadState a m => Setter' a Bool -> Bool -> m ()
- (||=) :: MonadState a m => Setter' a Bool -> Bool -> m ()
- (<>=) :: (Monoid o, MonadState a m) => Setter' a o -> o -> m ()
- (%!=) :: MonadState a m => Setter a a b b' -> (b -> b') -> m ()
- (+!=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (-!=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (*!=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()
- (//!=) :: (MonadState a m, Fractional b) => Setter' a b -> b -> m ()
- (&&!=) :: MonadState a m => Setter' a Bool -> Bool -> m ()
- (||!=) :: MonadState a m => Setter' a Bool -> Bool -> m ()
- (<>!=) :: (Monoid o, MonadState a m) => Setter' a o -> o -> 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 a (b :: k) :: forall k. * -> k -> *
- type Setter a a' b b' = forall f. Identical f => LensLike f a a' b b'
- type Setter' a b = forall f. Identical f => LensLike' f a b
- class Applicative f => Identical (f :: * -> *)
- data StateT s (m :: * -> *) a
- class Monad m => MonadState s (m :: * -> *) | m -> s
- type Writer w = WriterT w Identity
- class Semigroup a => Monoid a
Documentation
zoom :: Monad m => LensLike' (Zooming m c) a b -> StateT b m c -> StateT a m c #
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 :: MonadState a m => FoldLike b a a' b b' -> m b Source #
use :: MonadState a m => Getter a a' b b' -> m b
Retrieve a field of the state
use :: (Monoid b, MonadState a m) => Fold a a' b b' -> m b
Retrieve a monoidal summary of all the referenced fields from the state
uses :: MonadState a m => FoldLike r a a' b b' -> (b -> r) -> m r Source #
uses :: (MonadState a m, Monoid r) => Fold a a' b b' -> (b -> r) -> m r
Retrieve all the referenced fields from the state and foldMap the results together with f :: b -> r
.
uses :: MonadState a m => Getter a a' b b' -> (b -> r) -> m r
Retrieve a field of the state and pass it through the function f :: b -> r
.
uses l f = f <$> use l
(%=) :: MonadState a m => Setter a a b b' -> (b -> b') -> m () infix 4 Source #
Modify a field of the state.
assign :: MonadState a m => Setter a a b b' -> b' -> m () Source #
Set a field of the state.
(.=) :: MonadState a m => Setter a a b b' -> b' -> m () infix 4 Source #
Set a field of the state.
(%%=) :: MonadState a m => LensLike (Writer c) a a b b' -> (b -> (c, b')) -> m c infix 4 Source #
(%%=) :: MonadState a m => Lens a a b b' -> (b -> (c, b')) -> m c
Modify a field of the state while returning another value.
(%%=) :: (MonadState a m, Monoid c) => Traversal a a b b' -> (b -> (c, b')) -> m c
Modify each field of the state and return the mconcat
of the other values.
(<~) :: MonadState a m => Setter a a b b' -> m b' -> m () infixr 2 Source #
Set a field of the state using the result of executing a stateful command.
Compound Assignments
(//=) :: (MonadState a m, Fractional b) => Setter' a b -> b -> m () infixr 4 Source #
(<>=) :: (Monoid o, MonadState a m) => Setter' a o -> o -> m () infixr 4 Source #
Monoidally append a value to all referenced fields of the state.
Strict Assignments
(%!=) :: MonadState a m => Setter a a b b' -> (b -> b') -> m () infix 4 Source #
Strictly modify a field of the state.
(//!=) :: (MonadState a m, Fractional b) => Setter' a b -> b -> m () infixr 4 Source #
Types
data Zooming (m :: * -> *) 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
data Constant a (b :: k) :: forall k. * -> k -> * #
Constant functor.
Instances
class Applicative f => Identical (f :: * -> *) #
extract
Instances
Identical Identity | |
Defined in Lens.Family.Identical | |
Identical f => Identical (Backwards f) | |
Defined in Lens.Family.Identical | |
(Identical f, Identical g) => Identical (Compose f g) | |
Defined in Lens.Family.Identical |
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.
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 | |
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 :: * -> *) | 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 (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 (ReaderT r 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) | |
class Semigroup a => Monoid a #
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
x
<>
mempty
= xmempty
<>
x = xx
(<>
(y<>
z) = (x<>
y)<>
zSemigroup
law)mconcat
=foldr
'(<>)'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
.
NOTE: Semigroup
is a superclass of Monoid
since base-4.11.0.0.
Instances
Monoid Ordering | Since: base-2.1 |
Monoid () | Since: base-2.1 |
Monoid All | Since: base-2.1 |
Monoid Any | Since: base-2.1 |
Monoid IntSet | |
Monoid [a] | Since: base-2.1 |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
Monoid a => Monoid (Identity a) | |
Monoid (First a) | Since: base-2.1 |
Monoid (Last a) | Since: base-2.1 |
Monoid a => Monoid (Dual a) | Since: base-2.1 |
Monoid (Endo a) | Since: base-2.1 |
Num a => Monoid (Sum a) | Since: base-2.1 |
Num a => Monoid (Product a) | Since: base-2.1 |
Monoid (IntMap a) | |
Ord a => Monoid (Set a) | |
Monoid (MergeSet a) | |
Monoid b => Monoid (a -> b) | Since: base-2.1 |
(Monoid a, Monoid b) => Monoid (a, b) | Since: base-2.1 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
Ord k => Monoid (Map k v) | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | Since: base-2.1 |
Monoid a => Monoid (Const a b) | |
Alternative f => Monoid (Alt f a) | Since: base-4.8.0.0 |
Monoid a => Monoid (Constant a b) | |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | Since: base-2.1 |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) | Since: base-2.1 |