Skip to content

Commit

Permalink
Update and uniformise lists specs
Browse files Browse the repository at this point in the history
Uniformise specs to adhere to the proposed
[EEP 71](erlang/eep#63).

Many specs use `when` constraints and `::` inconsistenly, making
it hard for type-checkers to reason about.

For example,
```
-spec reverse(List1) -> List2 when
      List1 :: [T],
      List2 :: [T],
      T :: term().
```
in this spec, `List1` and `List2` are arguably defined as aliases
for `[T]`, while `T` is defined to be "a subtype of" `term()`.

Removing the last constraint makes it clearer that the returned
list has the same type as the input list:
```
-spec reverse(List1) -> List2 when
      List1 :: [T],
      List2 :: [T].
```

This PR unifies all specs of the lists module under this principle,
while minimising the amount of changes to specs: it keeps the spirit
of using aliases and `when` constraints instead of inlining types.
  • Loading branch information
VLanvin committed Aug 20, 2024
1 parent 50cc3be commit 8c148ab
Showing 1 changed file with 179 additions and 277 deletions.
Loading

0 comments on commit 8c148ab

Please sign in to comment.