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).