Looks interesting, but how does it compare
to https://hex.pm/packages/short_maps as it adds a sigil that does
something similar?
```elixir
import ShortMaps
my_map = %{foo: 1, bar: 2, baz: 3}
~m(foo bar baz)a = my_map
foo #=> 1
import ShortMaps
name = "Meg"
# String keys by default (or with the 's' modifier)~m(name) #=> %{"name" =>
"Meg"}# Atom keys with the 'a' modifier~m(name)a #=> %{name: "Meg"}
iex(1)> import ShortMapsnil
iex(2)> name = "Meg""Meg"
iex(3)> ~m(^name)a = %{name: "Meg"}
%{name: "Meg"}
iex(4)> ~m(^name)a = %{name: "Megan"}** (MatchError) no match of right hand
side value: %{name: "Megan"}
```
And other stuff
On Sunday, August 28, 2016 at 11:13:55 AM UTC-6, Hassan Zamani wrote:
>
> No comments?
>
> On Saturday, August 13, 2016 at 2:53:56 PM UTC+4:30, Hassan Zamani wrote:
>>
>> I would appreciate hearing your thoughts on
>> https://github.com/hzamani/synex. It has two macros: keys and params,
>> first one for expansion of atom-value pairs in keyword lists, maps and
>> structs, and other for expansion of string-value pairs in maps. Both of
>> them have variable pinning and map update support and params supports
>> nested maps:
>>
>> iex> params(%{a => %{b, c}}) = %{"a" => %{"b" => 2, "c" => 3}}
>> iex> a
>> %{"b" => 2, "c" => 3}
>> iex> c
>> 3
>>
>> Hassan
>>
>> On Wednesday, February 17, 2016 at 1:29:31 PM UTC+3:30, Jaap Frolich
>> wrote:
>>>
>>> Very nice Johan,
>>>
>>> Love the power of macros. Is there any resolution if this will make the
>>> standard library? I have a lot of repetition in my maps as well in my
>>> current app, and this is one of the things I like in ES6 that I really miss
>>> in Elixir (mostly it is of course the other way around ;)).
>>>
>>> Cheers,
>>>
>>> Jaap
>>>
>>> On Monday, August 10, 2015 at 4:57:02 PM UTC+8, Johan Wärlander wrote:
>>>>
>>>> After playing around a bit with the ~m sigil, I proposed a couple of
>>>> updates (one which touched on work that Andrea had alredy done, but with a
>>>> twist); short_maps now support the following:
>>>>
>>>> # Equality checks
>>>> foo = 1
>>>> bar = 2
>>>> ~m(foo bar)a == %{foo: 1, bar: 2} #=> true
>>>>
>>>> # Matching
>>>> ~m(foo bar)a = %{foo: 12, bar: "baaz"}
>>>> foo #=> 12
>>>>
>>>> # Pinning (NEW)
>>>> foo = 1
>>>> ~m(^foo bar)a = %{foo: 1, bar: "baaz"} #=> %{foo: 1, bar: "baaz"}
>>>> ~m(^foo bar)a = %{foo: 5, bar: "baaz"} #=> MatchError
>>>>
>>>> # Structs, when first word starts with '%' (NEW)
>>>> defmodule Foo do
>>>> defstruct bar: nil
>>>> end
>>>> ~m(%Foo bar)a = %Foo{bar: "baaz"}
>>>> bar #=> "baaz"
>>>>
>>>> For anyone else interested, please do get the latest version from
>>>> Andrea's repository (https://github.com/whatyouhide/short_maps), then
>>>> play around with it and see how it feels.
>>>>
>>>> On Friday, June 19, 2015 at 12:02:36 PM UTC+2, Andrea Leopardi wrote:
>>>>>
>>>>> I stood against the %{foo, bar, baz} syntax and deemed that too
>>>>> implicit, but I'm in favour of a possible ~m sigil. I think it may
>>>>> still be a bit implicit, but I can see it would make code much more
>>>>> concise
>>>>> in a lot of situations. I took a stab at it and wrote a simple
>>>>> implementation for such sigil, here
>>>>> <https://github.com/whatyouhide/short_maps>. We can try it out and
>>>>> see if we like it (and please, have a look at the implementation as well
>>>>> as
>>>>> I'm not sure it's bulletproof).
>>>>>
>>>>>
>>>>>
>>>>> On Sunday, May 31, 2015 at 12:19:46 PM UTC+2, Devin Torres wrote:
>>>>>>
>>>>>> Taking a pretty cool page out of ES6:
>>>>>>
>>>>>> # If `method`, `url`, `headers`, and `payload` are already bound
>>>>>> %Request{method, url, headers, payload}
>>>>>>
>>>>>> # If e.g. `payload` hasn't been bound yet
>>>>>> %Request{method, url, headers, payload: get_payload()}
>>>>>>
>>>>>
--
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/644cb7dd-917c-4d38-91ee-78021c8a2331%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.