Data.Lens.Common

data-lens-2.0.2: Haskell 98 Lenses

Data.Lens.Common

Contents

- Lens construction
- Functional API
- Operator API
- Pseudo-imperatives
- Stock lenses

Synopsis

- newtype Lens a b = Lens {
  - runLens :: a -> Store b a
  }
- lens :: (a -> b) -> (b -> a -> a) -> Lens a b
- iso :: (a -> b) -> (b -> a) -> Lens a b
- getL :: Lens a b -> a -> b
- setL :: Lens a b -> b -> a -> a
- modL :: Lens a b -> (b -> b) -> a -> a
- (^$) :: Lens a b -> a -> b
- (^$!) :: Lens a b -> a -> b
- (^.) :: a -> Lens a b -> b
- (^!) :: a -> Lens a b -> b
- (^=) :: Lens a b -> b -> a -> a
- (^!=) :: Lens a b -> b -> a -> a
- (^%=) :: Lens a b -> (b -> b) -> a -> a
- (^!%=) :: Lens a b -> (b -> b) -> a -> a
- (^%%=) :: Functor f => Lens a b -> (b -> f b) -> a -> f a
- (^+=) :: Num b => Lens a b -> b -> a -> a
- (^!+=) :: Num b => Lens a b -> b -> a -> a
- (^-=) :: Num b => Lens a b -> b -> a -> a
- (^!-=) :: Num b => Lens a b -> b -> a -> a
- (^*=) :: Num b => Lens a b -> b -> a -> a
- (^!*=) :: Num b => Lens a b -> b -> a -> a
- (^/=) :: Fractional b => Lens a b -> b -> a -> a
- (^!/=) :: Fractional b => Lens a b -> b -> a -> a
- fstLens :: Lens (a, b) a
- sndLens :: Lens (a, b) b
- mapLens :: Ord k => k -> Lens (Map k v) (Maybe v)
- intMapLens :: Int -> Lens (IntMap v) (Maybe v)
- setLens :: Ord k => k -> Lens (Set k) Bool
- intSetLens :: Int -> Lens IntSet Bool

# Documentation

newtype Lens a b

Constructors

Lens |
Fields runLens :: a -> Store b a

Instances

Category Lens |
Semigroupoid Lens |

# 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.

# Operator API

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

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

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

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

functional getter, which acts like a field accessor

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

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

(^%=) :: Lens a b -> (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

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

(^-=) :: Num b => Lens a b -> b -> a -> a

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

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

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

(^/=) :: Fractional 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)

intMapLens :: Int -> Lens (IntMap v) (Maybe v)

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

intSetLens :: Int -> Lens IntSet Bool