^. is for viewing - it's an alias for flip view where (simplifying) view :: Lens s a -> s -> a. The function ?~ is a modified alias for set over maybe types, where set :: Lens s a -> a -> s -> s. So we write the operator as:
(lens ?~ newValue) old = set lens newValue old
and the common pattern is to use old & lens ?~ newValue
^.
is for viewing - it's an alias forflip view
where (simplifying)view :: Lens s a -> s -> a
. The function?~
is a modified alias forset
over maybe types, whereset :: Lens s a -> a -> s -> s
. So we write the operator as:and the common pattern is to use
old & lens ?~ newValue