Skip to content
/ lens2 Public

Descended from the Lens library, with different interface and documentation, plus some utilities

License

Notifications You must be signed in to change notification settings

marick/lens2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lens2

Lens2 is a library for working with values deep within a nested data structure.

For reasons why you might prefer it to Elixir's built-in Kernel.update_in and friends, see "Are lenses worth it to you?".

This library is descended from Lens. To see why it's a different project, see the rationale. The short version is:

  1. Lots of beginner and intermediate documentation.
  2. An alternate API for operating on data with lenses (but the same API for creating lenses).
  3. Operations that encourage (but do not require) information hiding.
  4. Extra lenses and utility functions.

Installation

The package can be installed by adding it to your list of dependencies in mix.exs:

def deps do
  [
    {:lens2, "~> 0.2"},
  ]
end

TODO?

  • Consider separating :get and :get_and_update cases.
    • some performance advantage for lists
    • Lens.at would work with Enumerables for getting.
    • Makes writing def_raw_maker style lenses more complicated.
  • Make Deeply.pop?
  • Fix the bug where Deeply.update(["0", "1"], Lens.at(2), &Integer.parse/1) calls the update function with a nil.
  • Figure out if it's possible to make TypedStructLens work with this, or include a Lens2.TypedStructLens.
  • add defmakerp

About

Descended from the Lens library, with different interface and documentation, plus some utilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages