& package:lens

& 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"
This can be used to chain lens operations using op= syntax rather than op~ syntax for simple non-type-changing cases.
>>> (10,20) & _1 .~ 30 & _2 .~ 40
(30,40)
>>> (10,20) &~ do _1 .= 30; _2 .= 40
(30,40)
This does not support type-changing assignment, e.g.
>>> (10,20) & _1 .~ "hello"
("hello",20)
Modify the target(s) of a Lens', Iso, Setter or Traversal by taking their logical && with a value.
>>> execState (do _1 &&= True; _2 &&= False; _3 &&= True; _4 &&= False) (True,True,False,False)
(True,False,False,False)
(&&=) :: MonadState s m => Setter' s Bool    -> Bool -> m ()
(&&=) :: MonadState s m => Iso' s Bool       -> Bool -> m ()
(&&=) :: MonadState s m => Lens' s Bool      -> Bool -> m ()
(&&=) :: MonadState s m => Traversal' s Bool -> Bool -> m ()
Logically && the target(s) of a Bool-valued Lens or Setter.
>>> both &&~ True $ (False, True)
(False,True)
>>> both &&~ False $ (False, True)
(False,False)
(&&~) :: Setter' s Bool    -> Bool -> s -> s
(&&~) :: Iso' s Bool       -> Bool -> s -> s
(&&~) :: Lens' s Bool      -> Bool -> s -> s
(&&~) :: Traversal' s Bool -> Bool -> s -> s
Logically && a Boolean valued Lens into your Monad's state and return the result. When you do not need the result of the operation, (&&=) is more flexible.
(<&&=) :: MonadState s m => Lens' s Bool -> Bool -> m Bool
(<&&=) :: MonadState s m => Iso' s Bool  -> Bool -> m Bool
Logically && a Boolean valued Lens and return the result. When you do not need the result of the operation, (&&~) is more flexible.
(<&&~) :: Lens' s Bool -> Bool -> s -> (Bool, s)
(<&&~) :: Iso' s Bool  -> Bool -> s -> (Bool, s)
Flipped version of <$>.
(<&>) = flip fmap

Examples

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
Modify the target of a Lens into your Monad's state by taking its logical && with a value and return the old value that was replaced. When you do not need the result of the operation, (&&=) is more flexible.
(<<&&=) :: MonadState s m => Lens' s Bool -> Bool -> m Bool
(<<&&=) :: MonadState s m => Iso' s Bool -> Bool -> m Bool
Logically && the target of a Bool-valued Lens and return the old value. When you do not need the old value, (&&~) is more flexible.
>>> (False,6) & _1 <<&&~ True
(False,(False,6))
>>> ("hello",True) & _2 <<&&~ False
(True,("hello",False))
(<<&&~) :: Lens' s Bool -> Bool -> s -> (Bool, s)
(<<&&~) :: Iso' s Bool -> Bool -> s -> (Bool, s)
Modify the target(s) of a Lens', Setter' or Traversal' by computing its bitwise .&. with another value.
>>> execState (do _1 .&.= 15; _2 .&.= 3) (7,7)
(7,3)
(.&.=) :: (MonadState s m, Bits a) => Setter' s a    -> a -> m ()
(.&.=) :: (MonadState s m, Bits a) => Iso' s a       -> a -> m ()
(.&.=) :: (MonadState s m, Bits a) => Lens' s a      -> a -> m ()
(.&.=) :: (MonadState s m, Bits a) => Traversal' s a -> a -> m ()
Bitwise .&. the target(s) of a Lens or Setter.
>>> _2 .&.~ 7 $ ("hello",254)
("hello",6)
(.&.~) :: Bits a             => Setter s t a a    -> a -> s -> t
(.&.~) :: Bits a             => Iso s t a a       -> a -> s -> t
(.&.~) :: Bits a             => Lens s t a a      -> a -> s -> t
(.&.~) :: (Monoid a, Bits a) => Traversal s t a a -> a -> s -> t
Modify the target(s) of a Lens' (or Traversal') by computing its bitwise .&. with another value, returning the result (or a monoidal summary of all of the results traversed).
>>> runState (_1 <.&.= 15) (31,0)
(15,(15,0))
(<.&.=) :: (MonadState s m, Bits a)           => Lens' s a      -> a -> m a
(<.&.=) :: (MonadState s m, Bits a, Monoid a) => Traversal' s a -> a -> m a
Bitwise .&. the target(s) of a Lens or Traversal, returning the result (or a monoidal summary of all of the results).
>>> _2 <.&.~ 7 $ ("hello",254)
(6,("hello",6))
(<.&.~) :: Bits a             => Iso       s t a a -> a -> s -> (a, t)
(<.&.~) :: Bits a             => Lens      s t a a -> a -> s -> (a, t)
(<.&.~) :: (Bits a, Monoid a) => Traversal s t a a -> a -> s -> (a, t)
Modify the target(s) of a Lens', (or Traversal') by computing its bitwise .&. with another value, returning the original value (or a monoidal summary of all the original values). When you do not need the old value, (.&.=) is more flexible.
>>> runState (_1 <<.&.= 15) (31,0)
(31,(15,0))
(<<.&.=) :: (MonadState s m, Bits a)           => Lens' s a      -> a -> m a
(<<.&.=) :: (MonadState s m, Bits a, Monoid a) => Traversal' s a -> a -> m a
Bitwise .&. the target(s) of a Lens or Traversal, and return the original value, or a monoidal summary of the original values. When you do not need the old value, (.&.~) is more flexible.
>>> _2 <<.&.~ 7 $ ("hello", 254)
(254,("hello",6))
(<<.&.~) ::  Bits a            => Iso s t a a       -> a -> s -> (a, t)
(<<.&.~) ::  Bits a            => Lens s t a a      -> a -> s -> (a, t)
(<<.&.~) :: (Bits a, Monoid a) => Traversal s t a a -> a -> s -> (a, t)