Greg is right. In Elixir 1.3 it'll become possible to access map fields when using get_in(). So the first code snippet from the original post may become this
foo = get_in(Enum.find(list, &some_check/1), [Access.field(:bar)]) However, given the fact that OP uses both field access and Map.get, it's not clear what the actual desired behaviour is. Maybe this would suffice foo = get_in(Enum.find(list, &some_check/1), [:bar]) which already works in Elixir 1.2.x. On Fri, May 27, 2016 at 4:46 PM, Greg Vaughn <[email protected]> wrote: > I think you'll be able to achieve this cleanly with Kernel.get_in and > Kernel.update_in with Elixir 1.3. I'm sure there's more info somewhere, but > this is the extent of my knowledge at this time: > https://twitter.com/elixirlang/status/735942800039088129 > > -Greg > > > On May 27, 2016, at 6:56 AM, Thijs Klaver <[email protected]> wrote: > > > > Hello, > > > > In the same sense as Enum.filter_map/3, Enum.map_join/3, I propose > Enum.find_map/4 (or Enum.find_transform/4). > > Right now you would do something like > > > > foo = > > Enum.find list, nil, fn item -> some_check(item) end > > |> if(foo, do: foo.bar) > > > > With Enum.find_map you could do something like this > > > > foo = Enum.find list, nil, fn item -> some_check(item) end, fn item -> > Map.get item, :bar end > > > > This way you don't have to check if Enum.find actually found something > before transforming it. > > > > -- > > 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/8d31a0c3-1902-480b-aeb7-38182726c884%40googlegroups.com > . > > For more options, visit https://groups.google.com/d/optout. > > -- > 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/8E2F654A-BB47-4896-87A2-1BE0A8160AD9%40gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAAPY6eNtLVh%3DsDUimB%3Dm2dGV_Z%2B2dV0wHvnGb-_0ihbhf8YhjA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
