[erlang-questions] type specification of functions with same signature
Sat Oct 22 20:48:53 CEST 2016
let's say we have two function specifications:
-spec foo(list(), atom()) -> boolean().
-spec bar(list(), atom()) -> boolean().
is it possible to do something like this:
-type my_f() :: fun ((list(),atom())->boolean()).
-spec foo :: my_f().
-spec bar :: my_f().
i couldn't find a way of doing this
this would remove code duplication in type specifications
also i think it would make code *much* clearer
for example (bad one):
in higher order function
-spec hfoo(T,F) -> ok when
T :: any(),
F :: my_f().
-spec my_algorithm :: module1:my_f().
here i can express with type specification that i'm implementing function
that will be compatible with module1:hfoo/2 and possible others
is there way to achieve this in current erlang and if not are there any
plans to include something similar in future versions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions