lens package:lens-family-core

lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
Build a lens from a getter and setter family. Caution: In order for the generated lens family to be well-defined, you must ensure that the three lens laws hold:
  • getter (setter s a) === a
  • setter s (getter s) === s
  • setter (setter s a1) a2 === setter s a2
Haskell 2022 Lens Families This package provides first class(†) functional references in Van Laarhoven style supporting the following optics:
  • Lenses (view, over)
  • Traversals (toListOf, matching, over)
  • Setters (over)
  • Grates (zipWithOf, under, review)
  • Resetters (under)
  • Adapters (view, review)
  • Grids (toListOf, over / under, review)
  • Prisms (matching, over / under, review)
  • Getters (view)
  • Folders (toListOf)
  • Reviewers (review)
(†) For optimal first-class support use the lens-family package with rank 2 / rank N polymorphism. Lens.Family.Clone allows for first-class support of lenses and traversals for those who cannot support rank 2 polymorphism.
ALens s t a b is a universal Lens s t a b instance
ALens' s a is a universal Lens' s a instance
Converts a universal lens instance back into a polymorphic lens.