[erlang-questions] type specification of functions with same signature

Kenneth Lakin <>
Sun Oct 23 01:01:15 CEST 2016


On 10/22/2016 03:43 PM, Karlo Kuna wrote:
> sure dialyzer will report error but callback functions are just one
> motivation, for me the first example is far more important
> as it reduces spec duplication which is annoying and not very expressive
> IMHO.

Oh, drat. Right. You want to be able to vary the names of the function.
You probably already thought about this, but how about a macro?

-define(MY_F_SPEC(Fun), -spec Fun(list(),atom())->boolean()).

?MY_F_SPEC(foo).
foo(L, A) -> true.

?MY_F_SPEC(bar).
bar(L, A) -> false.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161022/274b9d1e/attachment.bin>


More information about the erlang-questions mailing list