1

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?

Max Heiber
  • 14,346
  • 12
  • 59
  • 97

1 Answers1

3

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

Lukas
  • 5,182
  • 26
  • 17