optics-operators-0.1.0.1: A tiny package containing operators missing from the official package.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Optics.Operators

Synopsis

Documentation

(+=) :: (Is k A_Setter, MonadState s m, Num a) => Optic' k is s a -> a -> m () infixr 4 Source #

Modify the target of the optic by adding a value.

data Person = Person { age :: Int } deriving (Generic)

f :: MonadState Person m => m ()
f = #age += 1

(-=) :: (Is k A_Setter, MonadState s m, Num a) => Optic' k is s a -> a -> m () infixr 4 Source #

Modify the target of the optic by subtracting a value.

data Person = Person { age :: Int } deriving (Generic)

f :: MonadState Person m => m ()
f = #age -= 1

(*=) :: (Is k A_Setter, MonadState s m, Num a) => Optic' k is s a -> a -> m () infixr 4 Source #

Modify the target of the optic by multiplying a value.

data Person = Person { age :: Int } deriving (Generic)

f :: MonadState Person m => m ()
f = #age *= 1

(//=) :: (Is k A_Setter, MonadState s m, Fractional a) => Optic' k is s a -> a -> m () infixr 4 Source #

Modify the target of the optic by dividing a value.

data Person = Person { age :: Int } deriving (Generic)

f :: MonadState Person m => m ()
f = #age //= 1