defgaurd
is a macro and as such it expects to receive Elixir AST as its arguments and it will return Elixir AST as its result. So the type of defguard
is really something similar to:
@spec is_pos_integer(Macro.t) :: Macro.t
Which, as you are probably already saying, isn’t very illuminating and partially why adding specs to a defguard
isn’t particularly useful.
I typically just add a @doc
block to defguard
a to document the underlying semantics.