This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.1 2.0.0
Accessors, a library implementing lenses for Elm.
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2018-07-14 11:01:19 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

README

The Accessors library

This library provides a way to manipulate nested datastructures without handling the unpacking, repacking and conditional checks that may occur along the way.

Using accessor combinators

Using combinators works in two parts: first you compose a series of combinators in order to describe which data you want to access.

let myAccessor = (recordFoo << onEach << recordBar)

Then you use an access function to determine which kind of operation you want to do.

myData = {foo = [ {bar = 3}
                , {bar = 2}
                , {bar = 0}
                ]
         }

getter   = get myAccessor myData          -- returns [3, 2, 0]
setter   = set myAccessor 2 myData        -- returns {foo = [{bar = 3}, {bar = 2}, {bar = 0}] }
transorm = over myAccessor (*2) myData    -- returns {foo = [{bar = 6}, {bar = 4}, {bar = 0}] }

Writing your own Accessor combinator

See the example of record accessor in src/Accessors.elm

Contribute

build

elm make

run tests

elm test

If you write new accessor combinators that rely on elm-lang datastructures, I'll be happy to review and merge. Please include tests for your combinators.