optics-core-0.1

Safe HaskellNone
LanguageHaskell2010

Optics.Operators

Description

Defines some infix operators for optics operations.

These are not exported by default from Optics. They have to be imported separately.

Synopsis

Documentation

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

>>> 5 & (+1) & show
"6"

Since: base-4.8.0.0

(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 #

Flipped version of <$>.

(<&>) = flip fmap

Examples

Expand

Apply (+1) to a list, a Just and a Right:

>>> Just 2 <&> (+1)
Just 3
>>> [1,2,3] <&> (+1)
[2,3,4]
>>> Right 3 <&> (+1)
Right 4

Since: base-4.11.0.0

(^.) :: ViewableOptic k a => s -> Optic' k is s a -> ViewResult k a infixl 8 #

Flipped infix version of view.

(^..) :: Is k A_Fold => s -> Optic' k is s a -> [a] infixl 8 #

Flipped infix version of toListOf.

(^?) :: Is k A_Fold => s -> Optic' k is s a -> Maybe a infixl 8 #

Flipped infix version of preview.

(#) :: Is k A_Review => b -> Optic' k is t b -> t infixr 8 #

Flipped infix version of review.

(%~) :: Is k A_Setter => Optic k is s t a b -> (a -> b) -> s -> t infixr 4 #

Infix version of over.

(.~) :: Is k A_Setter => Optic k is s t a b -> b -> s -> t infixr 4 #

Infix version of set.