Safe Haskell | Safe-Inferred |
---|

- 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, 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 (Getting r) a a' b b'
- type Setter a a' b b' = LensLike Setting a a' b b'
- type Setter' a b = Setter a a b b
- data StateT s m a
- class Monad m => MonadState s m | m -> s
- 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

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, Moand 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 bSource

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 rSource

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 ()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 ()Source

Set a field of the state.

(%%=) :: MonadState a m => LensLike (Writer c) a a b b' -> (b -> (c, b')) -> m cSource

(%%=) :: 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.

# Compound Assignments

(+=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()Source

(-=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()Source

(*=) :: (MonadState a m, Num b) => Setter' a b -> b -> m ()Source

(//=) :: (MonadState a m, Fractional b) => Setter' a b -> b -> m ()Source

(<>=) :: (Monoid o, MonadState a m) => Setter' a o -> o -> m ()Source

Monoidally append a value to all referenced fields of the state.

# Types

data Zooming m c a

# Re-exports

type LensLike f a a' b b' = (b -> f b') -> a -> f a'

type LensLike' f a b = (b -> f b) -> a -> f a

data StateT s m a

Monad m => MonadState s (StateT s m) | |

MonadTrans (StateT s) | |

Monad m => Monad (StateT s m) | |

Functor m => Functor (StateT s m) | |

MonadFix m => MonadFix (StateT s m) | |

MonadPlus m => MonadPlus (StateT s m) | |

(Functor m, Monad m) => Applicative (StateT s m) | |

(Functor m, MonadPlus m) => Alternative (StateT s m) | |

MonadIO m => MonadIO (StateT s m) |

class Monad m => MonadState s m | m -> s

MonadState s m => MonadState s (MaybeT m) | |

MonadState s m => MonadState s (ListT m) | |

MonadState s m => MonadState s (IdentityT 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) | |

(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) |

type Writer w = WriterT w Identity

class Monoid a

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.

Minimal complete definition: `mempty`

and `mappend`

.

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 (Dual a) | |

Monoid (Endo a) | |

Num a => Monoid (Sum a) | |

Num a => Monoid (Product a) | |

Monoid (First a) | |

Monoid (Last a) | |

Monoid a => Monoid (Maybe a) | Lift a semigroup into |

Monoid (IntMap a) | |

Ord a => Monoid (Set a) | |

Monoid b => Monoid (a -> b) | |

(Monoid a, Monoid b) => Monoid (a, b) | |

Ord k => Monoid (Map k v) | |

(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | |

(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) |