[erlang-questions] maps match specifications

Lukas Larsson garazdawi@REDACTED
Mon Jun 23 09:50:06 CEST 2014


Hello!

At the moment only the guards bifs operating on maps are supported in
match-specs. i.e. you can do this:

1> Tid = ets:new(test,[]).
16400
2> ets:insert(Tid,[{#{ a => b },2},{a,3},{#{ a => b, c => d},4}]).
true
4>
ets:select(Tid,[{{'$1','$2'},[{'and',{is_map,'$1'},{'==',{map_size,'$1'},1}}],['$2']}]).
[2]

but not any work with the values within a map.

Lukas


On Wed, Jun 18, 2014 at 4:57 PM, Daniel Goertzen <daniel.goertzen@REDACTED>
wrote:

> Maps match specifications are not working for me (see below).  I know they
> were absent in the early maps branch, but I could not find anything saying
> they are absent from R17.  I suspect they are just absent, but thought I
> would ask in case I've done something stupid or stumbled on a bug
>
> Thanks,
> Dan.
>
>
> 12> ets:fun2ms(fun({_,#{foo:=bar}}) -> true end).
> ** exception error: no function clause matching
> ms_transform:normalise({map,1,[{map_field_exact,1,{atom,1,foo},{atom,1,bar}}]})
> (ms_transform.erl, line 1063)
>      in function  ms_transform:normalise_list/1 (ms_transform.erl, line
> 1091)
>      in call from ms_transform:normalise_list/1 (ms_transform.erl, line
> 1091)
>      in call from ms_transform:normalise/1 (ms_transform.erl, line 1081)
>      in call from ms_transform:normalise_list/1 (ms_transform.erl, line
> 1091)
>      in call from ms_transform:normalise/1 (ms_transform.erl, line 1081)
>      in call from ms_transform:normalise/1 (ms_transform.erl, line 1079)
>      in call from ms_transform:transform_from_shell/3 (ms_transform.erl,
> line 215)
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140623/d3139d6f/attachment.htm>


More information about the erlang-questions mailing list