I implemented a tiny macro on my [Indifferent]( http://github.com/vic/indifferent) lib, `Indifferent.path` which just takes the access path and converts it to an "access function" as expected by `Kernel.get_in`, so maybe it could be of any use/inspiration here.
https://github.com/vic/indifferent/blob/master/lib/indifferent.ex#L80 On Wed, Dec 7, 2016 at 5:50 PM, Michał Muskała <[email protected]> wrote: > Good evening everybody. > > This is a moved discussion from https://github.com/elixir- > lang/elixir/issues/5548#issuecomment-265602755. > > Today, there's no way to work with structs in an easy way for the _in > functions. > > For static keys, everything is nice and shiny when working with both maps > and structs: > > update_in(foo.bar.buz, &(...)) > > Unfortunately as soon as we need to introduce a dynamic value, it suddenly > becomes extremely clunky in case of structs: > > update_in(foo.bar[key], &(...)) > # vs > update_in(foo, [Access.key!(:bar), Access.key(key)], &(...)) > > This is generally pushing me to work more with unstructured data in forms > of maps, the usability difference is huge. The Access is a very powerful > tool that helps to solve many problems in a concise way, it's unfortunate > structs have such a poor support. > > Michał. > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/4299E5C9-9C9B-411F-90FA-9EF7B6900327%40muskala.eu. > For more options, visit https://groups.google.com/d/optout. > -- vic Quaerendo invenietis. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK8a6WCc4exu7Q3oLeq%3DfeG2W06gZa5JZVA4cvHKtg422tp9wA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
