[erlang-questions] is it possible to reuse a "-type" specification for a function in a "-spec" ?
Marco Molteni
marco.molteni@REDACTED
Wed Jul 20 21:21:38 CEST 2016
Hello,
say I have a function that takes a function as an argument and I want
to write type specifications for them:
-type decider() :: fun((pos_integer(), #node{}) ->
reject | accept | continue).
-spec foo(Decider :: decider()) -> boolean().
foo(Decider) -> ...
When implementing the callback, I would like to reuse the type decider():
Instead of duplicating the same type information (error prone, can go
out of sync):
-spec my_cb(pos_integer(), #node{}) -> reject | accept | continue.
my_cb(X, Tree) -> ...
I would like to write something like:
-spec my_cb :: decider().
my_cb(X, Tree) -> ...
Is there a way?
thanks!
marco
More information about the erlang-questions
mailing list