whatyouhide / short_maps

⚠️Retired⚠️ library that provided a ~m sigil for ES6-like map destructuring in Elixir.
https://andrealeopardi.com/posts/a-story-of-regret-and-retiring-a-library-from-hex/
76 stars 5 forks source link

Mixed Atom/String #13

Closed OvermindDL1 closed 8 years ago

OvermindDL1 commented 8 years ago

Currently there is no way to have mixed atom/string representations. Any chance on having the default format (perhaps new sigil, M maybe) be something like:

~M(foo "bar" baz) = %{foo: 1, "bar" => 2, baz: 3}

foo # is 1
bar # is 2
baz # is 3

It would also be nice to be able to fallback to normal pattern matching for cases where the key is not easily turned into a variable, such as perhaps via:

~M(foo "bar" "a key"=>key 'complex-atom': an_atom_key 42=>a_num) = %{foo: 1, "bar" => 2, "a key" => 3, 'complex-atom': 4, 42 => 5}

foo # is 1
bar # is 2
key # is 3
an_atom_key # is 4
a_num # is 5

Or perhaps with commas?

Using some erlang code involves interesting mixed keys, not just string or atoms. :-)

whatyouhide commented 8 years ago

Hey @OvermindDL1, thanks for the issue!

I am 👎 on this for a few reasons:

Wdyt about this?

(Btw, closing this but feel free to reopen it if you feel my answer wasn't satisfying and want to keep the conversation going).

OvermindDL1 commented 8 years ago

It is mostly an erlang library integration thing yeah, so can understand that, not a use-case most deal with. :-)