Safe Haskell | Safe-Inferred |
---|
Views
The type definition of a view from a
to v
.
Views allow you to operate on part (the view) of a data structure (the whole) while abstracting the rest.
Note that while views are mostly used for operating on record fields, there are very interesting abstractions that may be conceived from them having nothing whatsoever to do with fields (for example, a view for the bounds of an array, that allows for easy redimensioning, or a view for the associated value to a given key in a map)
Usual Views
f_ :: (a -> v) -> View a vSource
A view that encapsulates a function.
Note: A View created with f_
is not a full View, as it doesn't allow
reinjection of the view into the whole. This function is thus to be
used only for convenience when chaining Views and pure functions.