view

View the value pointed to by a Getter, Iso or Lens or the result of folding over all the results of a Fold or Traversal that points at a monoidal value.
view . toid
>>> view (to f) a
f a
>>> view _2 (1,"hello")
"hello"
>>> view (to succ) 5
6
>>> view (_2._1) ("hello",("world","!!!"))
"world"
As view is commonly used to access the target of a Getter or obtain a monoidal summary of the targets of a Fold, It may be useful to think of it as having one of these more restricted signatures:
view ::             Getter s a     -> s -> a
view :: Monoid m => Fold s m       -> s -> m
view ::             Iso' s a       -> s -> a
view ::             Lens' s a      -> s -> a
view :: Monoid m => Traversal' s m -> s -> m
In a more general setting, such as when working with a Monad transformer stack you can use:
view :: MonadReader s m             => Getter s a     -> m a
view :: (MonadReader s m, Monoid a) => Fold s a       -> m a
view :: MonadReader s m             => Iso' s a       -> m a
view :: MonadReader s m             => Lens' s a      -> m a
view :: (MonadReader s m, Monoid a) => Traversal' s a -> m a
view is a synonym for (^.):
>>> view _1 (1, 2)
1
The reason it's not in Lens.Micro is that view in lens has a more general signature:
view :: MonadReader s m => Getting a s a -> m a
So, you would be able to use this view with functions, but not in various reader monads. For most people this shouldn't be an issue; if it is for you, use view from microlens-mtl.
create a view on a given bytearray This function update the offset and the size in order to guarantee:
  • offset >= 0
  • size >= 0
  • offset < length
  • size =< length - offset
Gets a value out of a structure using a getter.
view is a synonym for (^.), generalised for MonadReader (we are able to use it instead of (^.) since functions are instances of the MonadReader class):
>>> view _1 (1, 2)
1
When you're using Reader for config and your config type has lenses generated for it, most of the time you'll be using view instead of asks:
doSomething :: (MonadReader Config m) => m Int
doSomething = do
thingy        <- view setting1  -- same as “asks (^. setting1)”
anotherThingy <- view setting2
...
View the value pointed to by a getter. If you want to view a type-modifying optic that is insufficiently polymorphic to be type-preserving, use getting.
Run a Shell to completion, printing any unused values
view :: Getter s t a b -> s -> a
Demote a lens or getter to a projection function.
view :: Monoid a => Fold s t a b -> s -> a
Returns the monoidal summary of a traversal or a fold.
Deprecated: Use corresponding function from lens or microlens package
View function for inspecting the first instruction.
A convenient function for using view patterns when dispatching variants. For example:
myShow :: Var ("y" '::= String :| "x" '::= Int :| Empty) -> String
myShow (view x -> Just n) = "Int of "++show n
myShow (view y -> Just s) = "String of "++s
Set parameters of viewing a surface graph. See info:gnuplot/view
Deprecated: Use viewAssign or the Empty and :> patterns instead.
Combinator for the <view /> element.
Ask for part of read-only state.
view :: Getter s a -> s -> a
O(w). Set focus to the workspace with index 'i'. If the index is out of range, return the original StackSet. Xinerama: If the workspace is not visible on any Xinerama screen, it becomes the current screen. If it is in the visible list, it becomes current.
O(1) for the head, O(log n) for the tail. Find the item with minimal associated priority and remove it from the Heap (i. e. find head and tail of the heap) if it is not empty. Otherwise, Nothing is returned.
Explicitly set a diagram's bounding box, by giving the coordinates of the upper left and lower right corners (keeping in mind that the positive y-axis points downwards). Particularly useful for applying to the top-level diagram in order to only view a portion of it in the rendered output.