lens-family-0.0.1: Lens Families

Safe HaskellSafe-Infered

Lens.Family2.State.Lazy

Contents

Description

Lenses allow you to use fields of the state of a state monad as if they were variables in an imperative language. access is used to retrieve the value of a variable, and ~= and %= allow you to set and modify a variable. C-style compound assignments are also provided.

Synopsis

Documentation

focus :: Monad m => Lens a b -> StateT b m c -> StateT a m cSource

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.

access :: MonadState a m => Getter a b -> m bSource

Retrieve a field of the state

(%=) :: MonadState a m => Setter a b -> (b -> b) -> m ()Source

Modify a field of the state

(~=) :: MonadState a m => Setter a b -> b -> m ()Source

Set a field of the state

(%%=) :: MonadState a m => Lens a b -> (b -> (c, b)) -> m cSource

Modify a field of the state while returning another value

Compound Assignments

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

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