@spec for multiple functions

@vrod Depends …

For example dialyzer does not support it and therefore returns a warning about overlapping domains, see:

On the other side it looks much better when looking at generated documentation.

Finally there is 3rd way for your use case. You can write something like:

@spec foo({:ok | :good | :error, any}) :: any
def foo({:ok, x}), do: x
def foo({:good, x}), do: x
def foo({:error, x}), do: x
1 Like