Elixir - possible to combine custom map types?
Map.merge/2
won’t work for specs, it’s not a map actually, it’s just a similar syntax.
One might achieve the desired result with a bit of metaprogramming.
defmodule Test do
@map_a_type quote(do: [foo: String.t(), bar: String.t()])
@typep map_a :: %{unquote_splicing(@map_a_type)}
@typep map_b :: %{unquote_splicing(@map_a_type), baz: String.t()}
end