Need help with a 'required' macro

I don’t think a macro can return just the match part of a with (but happy to be wrong). Nevertheless, this looks more complex that the use case demands. Map.fetch!/2 does basically the same thing:

iex> Map.fetch!(%{a: "a"}, :a)
"a"
iex> Map.fetch!(%{a: "a"}, :b)
** (KeyError) key :b not found in: %{a: "a"}
    (stdlib 4.0) :maps.get(:b, %{a: "a"})

so you could simply:

with value <- Map.fetch!(map, key) do
  do_something()
end

Even in this case, its not very idiomatic since with’s value is to program “happy path” and therefore the with seems redundant in this example and the following would be the simplest:

var = Map.fetch!(%{a: "a"}, :a)