The feature to find the value inside the nested map.

Oliver Korpilla oliver.korpilla@REDACTED
Wed Jun 16 09:07:18 CEST 2021


Hello,

something like Lenses has been implemented in elixir with the get_in/2
and update_in/3 functions. I use these functions to great effect every
day for deep updates.

There is nothing in there that couldn't be done in Erlang as well. (My
apologies if somebody has already done so.)

These two functions have been much more useful to me than Lenses for
example in PureScript (a nice sibling of Haskell), due to the
loosey-goosey nature of BEAM's type system, much faster to write code in
comparison.

Due to immutability and reuse of sub-structures they can also be very
efficient.

Cheers,
Oliver

On 16.06.2021 09:01, Christophe De Troyer wrote:
> Hi,
>
> What you are describing can be done with "lenses". They're a
> functional construct to get/update data from nested data structures.
>
> While googling I found an older discussion on this mailiing list
> http://erlang.org/pipermail/erlang-questions/2015-September/086068.html.
> <http://erlang.org/pipermail/erlang-questions/2015-September/086068.html.>
>
> Hope that helps.
>
> - Christophe
>
> On 16 June 2021 04:04:38 CEST, "瀬川昂弘"
> <123430024@REDACTED> wrote:
>
>     Assuming,
>     Map = #{a => b,c => #{1 => 2,3 => 4,5 => #{x => y}}}.
>
>     Expected:
>     maps:new_find_fun(Key = 5, Map) = {ok,#{x => y}}.
>
>     It's useful there is the above feature, in my guess.
>
>     --
>     Takahiro Segawa.
>     E-mail:123430024@REDACTED
>     <mailto:123430024@REDACTED>
>
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus



More information about the erlang-questions mailing list