lens-family-core-0.1.0: Haskell 98 Lens Families

Safe HaskellSafe-Infered

Lens.Family.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 => Ref (Focusing m c) 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 :: Monad m => Getter a b -> StateT a m bSource

Retrieve a field of the state

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

Modify a field of the state

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

Set a field of the state

(%%=) :: Monad m => Ref (Focusing m c) a b -> (b -> (c, b)) -> StateT a m cSource

Modify a field of the state while returning another value

Compound Assignments

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

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

(<>=) :: (Monoid o, Monad m) => Setter a o -> o -> StateT a m ()Source

Types

data Focusing m c a Source

Instances

Monad m => Functor (Focusing m c)