-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
The goal is to provide accessors to be used alongside Kernel.put_in and friends. For example:
put_in sample[:foo][:bar], :baz
Can be thought as a shortcut to:
put_in sample, [Access.key(:foo), Access.key(:bar)], :baz
Where Access.key(:foo)
will return a function as described by Kernel.get_and_update_in
. Similar would exist for structs:
put_in sample.foo.bar, :baz
is equivalent to:
put_in sample, [Access.field(:foo), Access.field(:bar)], :baz
For now, we will also provide all/0
and at/1
for lists and elem/1
for tuples. The question is the naming convention for those functions. For example, we could prefix most of them by by_
: by_key
, by_elem
and by_field
, although it wouldn't work for all/0
and at/1
. Alternatively, we can drop the by_
prefix, although it could be confusing if mixed with the existing fetch/2
, get/3
and friends.
Thoughts?