>>> (a,b)^._2 b
>>> ("hello","world")^._2 "world"
>>> import Data.Complex >>> ((0, 1 :+ 2), 3)^._1._2.to magnitude 2.23606797749979
(^.) :: s -> Getter s a -> a (^.) :: Monoid m => s -> Fold s m -> m (^.) :: s -> Iso' s a -> a (^.) :: s -> Lens' s a -> a (^.) :: Monoid m => s -> Traversal' s m -> m
(^. _1) :: (a, b) -> a (^. _1) = fstWhen (^.) is used with a traversal, it combines all results using the Monoid instance for the resulting type. For instance, for lists it would be simple concatenation:
>>> ("str","ing") ^. each "string"The reason for this is that traversals use Applicative, and the Applicative instance for Const uses monoid concatenation to combine “effects” of Const. A non-operator version of (^.) is called view, and it's a bit more general than (^.) (it works in MonadReader). If you need the general version, you can get it from microlens-mtl; otherwise there's view available in Lens.Micro.Extras.
(^.) :: s -> Getter s t a b -> aAccess the value referenced by a getter or lens.
(^.) :: Monoid a => s -> Fold s t a b -> aAccess the monoidal summary referenced by a traversal or a fold.
>>> [[1,2],[3]]^..id [[[1,2],[3]]] >>> [[1,2],[3]]^..traverse [[1,2],[3]] >>> [[1,2],[3]]^..traverse.traverse [1,2,3]
>>> (1,2)^..both [1,2]
toList xs ≡ xs ^.. folded (^..) ≡ flip toListOf
(^..) :: s -> Getter s a -> a :: s -> Fold s a -> a :: s -> Lens' s a -> a :: s -> Iso' s a -> a :: s -> Traversal' s a -> a :: s -> Prism' s a -> [a]
>>> Just 3 ^.. _Just [3]Gathering all values in a list of tuples:
>>> [(1,2),(3,4)] ^.. each.each [1,2,3,4]
(^..) :: s -> Fold s t a b -> [a]Returns a list of all of the referenced values in order.