Why do type specs in OTP repeat parameter names?

97 Views Asked by At

In type specs for the Erlang standard library, there are almost never any types in the spec until the when clause. For example, the spec for lists:member/2 is like this:

-spec member(Elem, List) -> boolean() when
      Elem :: T,
      List :: [T],
      T :: term().

instead of:

-spec member(Elem :: T, List :: [T]) -> boolean() when
      T :: term().

Is there a reason for this? Are these two styles equivalent from the dialyzer's point of view?

1

There are 1 best solutions below

2
On BEST ANSWER

It is done that way because the documentation that is generated from the specs looks better if done like that.