-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add list types #13922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add list types #13922
Conversation
union(dynamic(list_tl_static(dynamic)), list_tl_static(static)) | ||
|
||
is_dynamic_list and only_list -> | ||
:not_non_empty_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to :empty_list
!
# Eliminate empty lists from the union TODO | ||
defp list_normalize(dnf), do: dnf | ||
# Enum.filter(dnf, fn {list_type, last_type, negs} -> | ||
# not Enum.any?(negs, fn neg -> subtype?(list_type, neg) end) | ||
# end) | ||
# end | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Eliminate empty lists from the union TODO | |
defp list_normalize(dnf), do: dnf | |
# Enum.filter(dnf, fn {list_type, last_type, negs} -> | |
# not Enum.any?(negs, fn neg -> subtype?(list_type, neg) end) | |
# end) | |
# end | |
# | |
# TODO: Eliminate empty lists from the union TODO | |
defp list_normalize(dnf), do: dnf | |
# Enum.filter(dnf, fn {list_type, last_type, negs} -> | |
# not Enum.any?(negs, fn neg -> subtype?(list_type, neg) end) | |
# end) | |
# end | |
def list(_arg), do: %{bitmap: @bit_list} | ||
def non_empty_list(_arg, _tail \\ empty_list()), do: %{bitmap: @bit_non_empty_list} | ||
|
||
# TODO: check emptiness here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check emptiness of what? :)
[to_quoted(list_type), to_quoted(last_type)] | ||
end | ||
|
||
if Enum.empty?(negs) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if Enum.empty?(negs) do | |
if negs == [] do |
end | ||
end | ||
|
||
def list_to_quoted(dnf) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def list_to_quoted(dnf) do | |
defp list_to_quoted(dnf) do |
Merged manually, thank you! |
Proper list types:
list()
list(integer())
a (possibly empty) list of integersImproper lists:
list(integer(), atom())
(a list of integers, with an atom at the tail)A type like
list(term(), term()
includes both propers lists and improper lists (sinceterm()
includesempty_list()
)Also includes
hd
andtl
operators, type-safe so using those on lists that may be empty will errorUsing
tl
on a improper list likelist(integer(), atom())
will return either a list of integers or anatom()
.The addition creates some warning for the compiler on patterns not matching, to be fixed :)