[erlang-questions] Deep data structures and lenses

Ulf Wiger ulf@REDACTED
Mon Sep 21 14:22:12 CEST 2015

> On 12 Sep 2015, at 19:51, Guilherme Andrade <g@REDACTED> wrote:
> Partially inspired by jlouis' erl-lenses[1] and an old discussion on this mailing list[2], I've been sketching a library for easier manipulation (both data fetching and updating) of deep data structures

Another library that’s been inspired by erl-lenses (although this has perhaps not been well communicated) is exprecs in parse_trans.





-record(r, {a, b, c}).

t() ->
    R = '#new-r'([{a,1},{b,2},{c,3}]),
    {GetA, SetA} = Lens = '#lens-r'(a),
    GetA1 = GetA(R),
    R1 = SetA(17, R),
    GetA2 = GetA(R1),
    [{lens, Lens},
     {get_a, GetA1},
     {set_a, 17, R1},
     {get_a, GetA2}].


Eshell V5.10.4  (abort with ^G)
1> c(lens).
2> lens:t().

Ulf W

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150921/c14f8378/attachment.htm>

More information about the erlang-questions mailing list