Skip to content

Instantly share code, notes, and snippets.

@wojtekmach
Created January 11, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wojtekmach/7d4b5dc2f45a4708ce04d19e7c381360 to your computer and use it in GitHub Desktop.
Save wojtekmach/7d4b5dc2f45a4708ce04d19e7c381360 to your computer and use it in GitHub Desktop.
@doc """
The MapSet sigil.
iex> ~MapSet{1, 2, [3, 4], ~MapSet[5]}
#MapSet<[1, 2, #MapSet<[5]>, [3, 4]]>
# but this of course wouldn't work due to sigil delimiter escaping:
# iex> ~MapSet{1, ~MapSet{2}}
"""
defmacro sigil_MapSet({:<<>>, _, [string]}, []) do
quoted = Code.string_to_quoted!("[" <> string <> "]")
quote do
MapSet.new(unquote(quoted))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment