talira

Lenses, folds and traversals for Haskell

open sourceBSD-2-Clausefree

lens is a Haskell library of lenses, isomorphisms, folds, traversals, getters and setters: composable optics for reading and updating parts of nested data structures. It comes with ready-made lenses for the types in common use and tools that generate lenses and isomorphisms for your own data types, and its Control.Lens combinators compose into a generic toolbox for working with structured data.

Problems it solves

  • update a field deep inside nested Haskell records without unpacking every level
  • generate getters and setters for my Haskell data types automatically
  • traverse and modify every matching element of a Haskell data structure

Features

  • lenses, prisms, isomorphisms, folds, traversals, getters and setters
  • generated lenses for user data types
  • batteries-included lenses for common types
  • Control.Lens combinators

Alternatives

The same job

These do what lens does.

  1. microlens A lightweight lens library for Haskell, compatible with lens
  2. optics Lenses, traversals and prisms for Haskell through an abstract interface
  3. indexed-traversable FunctorWithIndex, FoldableWithIndex and TraversableWithIndex for Haskell

Compare lens with the top 3