^. -package:lens-family-core

View the value pointed to by a Getter or Lens or the result of folding over all the results of a Fold or Traversal that points at a monoidal values. This is the same operation as view with the arguments flipped. The fixity and semantics are such that subsequent field accesses can be performed with (.).
>>> (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
(^.) applies a getter to a value; in other words, it gets a value out of a structure using a getter (which can be a lens, traversal, fold, etc.). Getting 1st field of a tuple:
(^. _1) :: (a, b) -> a
(^. _1) = fst
When (^.) 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.
The operator form of view with the arguments flipped.
Getting
Flipped infix version of view.
get as infix operator. This lets us write record^.field^.subfield. This imitates Modula II syntax.
Project a field of an entity.
(^.) :: s -> Getter s t a b -> a
Access the value referenced by a getter or lens.
(^.) :: Monoid a => s -> Fold s t a b -> a
Access the monoidal summary referenced by a traversal or a fold.
Deprecated: Use corresponding function from lens or microlens package
Field access, inspired by the lens library. This is merely reverse application, but allows us to write things like (1, 2)^._1 which is likely to be familiar to most Haskell programmers out there. Note that this is precisely equivalent to _1 (1, 2), but perhaps it reads a little nicer.
Get inner part i of structure o as designated by Lens' o i.
Infix version of getL (with the reverse order of the arguments)
Like view but with the arguments flipped
A convenient infix (flipped) version of toListOf.
>>> [[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]
s ^.. t returns the list of all values that t gets from s. A Maybe contains either 0 or 1 values:
>>> Just 3 ^.. _Just
[3]
Gathering all values in a list of tuples:
>>> [(1,2),(3,4)] ^.. each.each
[1,2,3,4]
Flipped infix version of toListOf.
Returns a list of all of the referenced values in order.
Deprecated: Use corresponding function from lens or microlens package
besides
Dot product of two vectors.
Infix version of xor.
An infix version of viewVar, meant to evoke parallels to ^. from lens. With normal values, you can extract something from that value with a lens:
x ^. myLens
would extract a piece of x :: b, specified by myLens :: Lens' b a. The result has type a.
xVar ^^. myLens
would extract a piece out of xVar :: BVar s b (a BVar holding a b), specified by myLens :: Lens' b a. The result has type BVar s a (a BVar holding a a) This is the main way to pull out values from BVar of container types. If you have control of your data type definitions, consider using splitBV, which lets you break out BVars of values into BVars of their individual fields automatically without requiring lenses. NOTE: Usage of ^^. on many fields from the same item is usually the main source of overhead in backprop code, if you are looking to optimize your code. See <https://backprop.jle.im/07-performance.html this performance guide> for more information, and details on mitigating this overhead. WARNING: Do not use with any lenses that operate "numerically" on the contents (like multiplying).
An infix version of toListOfVar, meant to evoke parallels to ^.. from lens. With normal values, you can extract all targets of a Traversal from that value with a:
x ^.. myTraversal
would extract all targets inside of x :: b, specified by myTraversal :: Traversal' b a. The result has type [a].
xVar ^^.. myTraversal
would extract all targets inside of xVar :: BVar s b (a BVar holding a b), specified by myTraversal :: Traversal' b a. The result has type [BVar s a] (A list of BVars holding as). NOTE: Has all of the performance overhead issues of sequenceVar; see documentation for sequenceVar for more information.