data-lens-2.10.0: Haskell 98 Lenses

Safe HaskellSafe-Infered

Data.Lens.Common

Contents

Synopsis

Documentation

newtype Lens a b

Constructors

Lens 

Fields

runLens :: a -> Store b a
 

Lens construction

lens :: (a -> b) -> (b -> a -> a) -> Lens a b

build a lens out of a getter and setter

iso :: (a -> b) -> (b -> a) -> Lens a b

build a lens out of an isomorphism

Functional API

getL :: Lens a b -> a -> b

Gets the getter function from a lens.

setL :: Lens a b -> b -> a -> a

Gets the setter function from a lens.

modL :: Lens a b -> (b -> b) -> a -> a

Gets the modifier function from a lens.

mergeL :: Lens a c -> Lens b c -> Lens (Either a b) c

Operator API

(^$), (^$!) :: Lens a b -> a -> b

(^.), (^!) :: a -> Lens a b -> b

functional getter, which acts like a field accessor

(^=), (^!=) :: Lens a b -> b -> a -> a

(^%=), (^!%=) :: Lens a b -> (b -> b) -> a -> a

functional modify

(^%%=) :: Functor f => Lens a b -> (b -> f b) -> a -> f a

functorial modify

Pseudo-imperatives

(^+=), (^!*=), (^*=), (^!-=), (^-=), (^!+=) :: Num b => Lens a b -> b -> a -> a

(^/=), (^!/=) :: Fractional b => Lens a b -> b -> a -> a

Stock lenses

fstLens :: Lens (a, b) a

sndLens :: Lens (a, b) b

mapLens :: Ord k => k -> Lens (Map k v) (Maybe v)

setLens :: Ord k => k -> Lens (Set k) Bool