Skip to content

Commit 62b3416

Browse files
committed
Change types to make Dialyzer happy
1 parent 64316b6 commit 62b3416

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

lib/bimap.ex

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,23 @@ defmodule BiMap do
4141
"""
4242

4343
@typedoc "Key type"
44-
@type k :: any
44+
@type k :: term
4545

4646
@typedoc "Value type"
47-
@type v :: any
47+
@type v :: term
4848

49-
@opaque t(k, v) :: %BiMap{
50-
keys: %{optional(k) => v},
51-
values: %{optional(v) => k}
52-
}
49+
@typedoc false
50+
@opaque internal_keys(k, v) :: %{optional(k) => v}
5351

54-
@type t :: t(any, any)
52+
@typedoc false
53+
@opaque internal_values(k, v) :: %{optional(v) => k}
54+
55+
@type t(k, v) :: %BiMap{
56+
keys: internal_keys(k, v),
57+
values: internal_values(k, v)
58+
}
59+
60+
@type t :: t(term, term)
5561

5662
defstruct keys: %{}, values: %{}
5763

lib/bimultimap.ex

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,27 @@ defmodule BiMultiMap do
3030
"""
3131

3232
@typedoc "Key type"
33-
@type k :: any
33+
@type k :: term
3434

3535
@typedoc "Value type"
36-
@type v :: any
36+
@type v :: term
3737

38-
@opaque t(k, v) :: %BiMultiMap{
39-
keys: %{optional(k) => MapSet.t(v)},
40-
values: %{optional(v) => MapSet.t(k)},
41-
size: non_neg_integer
42-
}
38+
@typedoc false
39+
@opaque internal_keys(k, v) :: %{optional(k) => MapSet.t(v)}
4340

44-
@type t :: t(any, any)
41+
@typedoc false
42+
@opaque internal_values(k, v) :: %{optional(v) => MapSet.t(k)}
43+
44+
@typedoc false
45+
@opaque internal_size :: non_neg_integer
46+
47+
@type t(k, v) :: %BiMultiMap{
48+
keys: internal_keys(k, v),
49+
values: internal_values(k, v),
50+
size: internal_size
51+
}
52+
53+
@type t :: t(term, term)
4554

4655
defstruct keys: %{}, values: %{}, size: 0
4756

0 commit comments

Comments
 (0)