[erlang-questions] Refactoring for edoc

Vance Shipley <>
Thu Jan 12 14:27:41 CET 2017


We've recently discovered that edoc generates much nicer documentation
when you write type specifications using `when` such as:

     -spec example(Number) -> {ok, Result} | {error, Reason}
          when  Number :: pos_integer(), Result = integer(), Reason :: term().

... rather than the more obvious:

     -spec example(Number :: pos_integer()) -> {ok, Result ::
integer()} | {error, Reason :: term()}.


So the question becomes how can we easily refactor all of our type
specifications to use the former method?  Is there a refactoring too
well suited to this job?

-- 
     -Vance


More information about the erlang-questions mailing list