Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Lens.Family.State.Strict
Description
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 :: forall (m :: Type -> Type) a s t b. Monad m => FoldLike a s t a b -> StateT s m a
- uses :: forall (m :: Type -> Type) r s t a b. Monad m => FoldLike r s t a b -> (a -> r) -> StateT s m r
- (%=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> (a -> b) -> StateT s m ()
- assign :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> b -> StateT s m ()
- (.=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> b -> StateT s m ()
- (%%=) :: forall (m :: Type -> Type) c s a b. Monad m => LensLike (Writer c) s s a b -> (a -> (c, b)) -> StateT s m c
- (<~) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> StateT s m b -> StateT s m ()
- (+=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (-=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (*=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (//=) :: forall (m :: Type -> Type) a s. (Monad m, Fractional a) => ASetter' s a -> a -> StateT s m ()
- (&&=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m ()
- (||=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m ()
- (<>=) :: forall (m :: Type -> Type) a s. (Monad m, Monoid a) => ASetter' s a -> a -> StateT s m ()
- (%!=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> (a -> b) -> StateT s m ()
- (+!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (-!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (*!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m ()
- (//!=) :: forall (m :: Type -> Type) a s. (Monad m, Fractional a) => ASetter' s a -> a -> StateT s m ()
- (&&!=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m ()
- (||!=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m ()
- (<>!=) :: forall (m :: Type -> Type) a s. (Monad m, Monoid a) => ASetter' s a -> a -> StateT s 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 ASetter s t a b = LensLike Identity s t a b
- type ASetter' s a = LensLike' Identity s a
- data Identity a
- data StateT s (m :: Type -> Type) a
- 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 :: forall (m :: Type -> Type) a s t b. Monad m => FoldLike a s t a b -> StateT s m a #
use :: Monad m => Getter s t a b -> StateT s m a
Retrieve a field of the state
use :: (Monad m, Monoid a) => Fold s t a b -> StateT s m a
Retrieve a monoidal summary of all the referenced fields from the state
uses :: forall (m :: Type -> Type) r s t a b. Monad m => FoldLike r s t a b -> (a -> r) -> StateT s m r #
uses :: (Monad m, Monoid r) => Fold s t a b -> (a -> r) -> StateT s m r
Retrieve all the referenced fields from the state and foldMap the results together with f :: a -> r
.
uses :: Monad m => Getter s t a b -> (a -> r) -> StateT s m r
Retrieve a field of the state and pass it through the function f :: a -> r
.
uses l f = f <$> use l
(%=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> (a -> b) -> StateT s m () infix 4 #
Modify a field of the state.
assign :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> b -> StateT s m () #
Set a field of the state.
(.=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> b -> StateT s m () infix 4 #
Set a field of the state.
(%%=) :: forall (m :: Type -> Type) c s a b. Monad m => LensLike (Writer c) s s a b -> (a -> (c, b)) -> StateT s m c infix 4 #
(%%=) :: Monad m => Lens s s a b -> (a -> (c, b)) -> StateT s m c
Modify a field of the state while returning another value.
(%%=) :: (Monad m, Monoid c) => Traversal s s a b -> (a -> (c, b)) -> StateT s m c
Modify each field of the state and return the mconcat
of the other values.
(<~) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> StateT s m b -> StateT s m () infixr 2 #
Set a field of the state using the result of executing a stateful command.
Compound Assignments
(+=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(-=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(*=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(//=) :: forall (m :: Type -> Type) a s. (Monad m, Fractional a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(&&=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m () infixr 4 #
(||=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m () infixr 4 #
(<>=) :: forall (m :: Type -> Type) a s. (Monad m, Monoid a) => ASetter' s a -> a -> StateT s m () infixr 4 #
Monoidally append a value to all referenced fields of the state.
Strict Assignments
(%!=) :: forall (m :: Type -> Type) s a b. Monad m => ASetter s s a b -> (a -> b) -> StateT s m () infix 4 #
Strictly modify a field of the state.
(+!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(-!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(*!=) :: forall (m :: Type -> Type) a s. (Monad m, Num a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(//!=) :: forall (m :: Type -> Type) a s. (Monad m, Fractional a) => ASetter' s a -> a -> StateT s m () infixr 4 #
(&&!=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m () infixr 4 #
(||!=) :: forall (m :: Type -> Type) s. Monad m => ASetter' s Bool -> Bool -> StateT s m () infixr 4 #
(<>!=) :: forall (m :: Type -> Type) a s. (Monad m, Monoid a) => ASetter' s a -> a -> StateT s m () infixr 4 #
Types
data Zooming (m :: Type -> Type) c a #
Instances
(Monoid c, Monad m) => Applicative (Zooming m c) # | |
Defined in Lens.Family.State.Zoom | |
Monad m => Functor (Zooming m c) # | |
Re-exports
Constant functor.
Instances
Generic1 (Constant a :: k -> Type) | |||||
Defined in Data.Functor.Constant Associated Types
| |||||
Bifoldable (Constant :: Type -> Type -> Type) | |||||
Bifunctor (Constant :: Type -> Type -> Type) | |||||
Bitraversable (Constant :: Type -> Type -> Type) | |||||
Defined in Data.Functor.Constant Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Constant a b -> f (Constant c d) # | |||||
Eq2 (Constant :: Type -> Type -> Type) | |||||
Ord2 (Constant :: Type -> Type -> Type) | |||||
Defined in Data.Functor.Constant | |||||
Read2 (Constant :: Type -> Type -> Type) | |||||
Defined in Data.Functor.Constant Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (Constant a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Constant a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (Constant a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [Constant a b] # | |||||
Show2 (Constant :: Type -> Type -> Type) | |||||
Eq a => Eq1 (Constant a :: Type -> Type) | |||||
Ord a => Ord1 (Constant a :: Type -> Type) | |||||
Defined in Data.Functor.Constant | |||||
Read a => Read1 (Constant a :: Type -> Type) | |||||
Defined in Data.Functor.Constant Methods liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (Constant a a0) # liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [Constant a a0] # liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (Constant a a0) # liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [Constant a a0] # | |||||
Show a => Show1 (Constant a :: Type -> Type) | |||||
Contravariant (Constant a :: Type -> Type) | |||||
Monoid a => Applicative (Constant a :: Type -> Type) | |||||
Defined in Data.Functor.Constant | |||||
Functor (Constant a :: Type -> Type) | |||||
Foldable (Constant a :: Type -> Type) | |||||
Defined in Data.Functor.Constant Methods fold :: Monoid m => Constant a m -> m # foldMap :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> Constant a a0 -> m # foldr :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> Constant a a0 -> b # foldl :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> Constant a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> Constant a a0 -> a0 # toList :: Constant a a0 -> [a0] # null :: Constant a a0 -> Bool # length :: Constant a a0 -> Int # elem :: Eq a0 => a0 -> Constant a a0 -> Bool # maximum :: Ord a0 => Constant a a0 -> a0 # minimum :: Ord a0 => Constant a a0 -> a0 # | |||||
Traversable (Constant a :: Type -> Type) | |||||
Defined in Data.Functor.Constant | |||||
Phantom (Constant a :: Type -> Type) # | |||||
Defined in Lens.Family.Phantom | |||||
Monoid a => Monoid (Constant a b) | |||||
Semigroup a => Semigroup (Constant a b) | |||||
(Typeable b, Typeable k, Data a) => Data (Constant a b) | |||||
Defined in Data.Functor.Constant Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Constant a b -> c (Constant a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Constant a b) # toConstr :: Constant a b -> Constr # dataTypeOf :: Constant a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Constant a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Constant a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Constant a b -> Constant a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Constant a b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Constant a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Constant a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Constant a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Constant a b -> m (Constant a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Constant a b -> m (Constant a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Constant a b -> m (Constant a b) # | |||||
Generic (Constant a b) | |||||
Defined in Data.Functor.Constant Associated Types
| |||||
Read a => Read (Constant a b) | |||||
Show a => Show (Constant a b) | |||||
Eq a => Eq (Constant a b) | |||||
Ord a => Ord (Constant a b) | |||||
Defined in Data.Functor.Constant | |||||
type Rep1 (Constant a :: k -> Type) | |||||
Defined in Data.Functor.Constant | |||||
type Rep (Constant a b) | |||||
Defined in Data.Functor.Constant |
Identity functor and monad. (a non-strict monad)
Examples
>>>
fmap (+1) (Identity 0)
Identity 1
>>>
Identity [1, 2, 3] <> Identity [4, 5, 6]
Identity [1,2,3,4,5,6]
>>> do x <- Identity 10 y <- Identity (x + 5) pure (x + y) Identity 25
@since base-4.8.0.0
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
MonadTrans (StateT s) | |||||
Defined in Control.Monad.Trans.State.Strict | |||||
MonadIO m => MonadIO (StateT s m) | |||||
Defined in Control.Monad.Trans.State.Strict | |||||
Contravariant m => Contravariant (StateT s m) | |||||
(Functor m, MonadPlus m) => Alternative (StateT s m) | |||||
(Functor m, Monad m) => Applicative (StateT s m) | |||||
Defined in Control.Monad.Trans.State.Strict | |||||
Functor m => Functor (StateT s m) | |||||
Monad m => Monad (StateT s m) | |||||
MonadPlus m => MonadPlus (StateT s m) | |||||
MonadFail m => MonadFail (StateT s m) | |||||
Defined in Control.Monad.Trans.State.Strict | |||||
MonadFix m => MonadFix (StateT s m) | |||||
Defined in Control.Monad.Trans.State.Strict | |||||
Generic (StateT s m a) | |||||
Defined in Control.Monad.Trans.State.Strict Associated Types
| |||||
type Rep (StateT s m a) | |||||
Defined in Control.Monad.Trans.State.Strict |