News for hackers. Stuff that matters.
Re:Typing Lists and Tuples in Elixir by josevalim on Wednesday August 28, 2024 @11:06AM (#41380356)
We (Elixir) would rather define lists on top of non empty lists:

    list(a) = empty_list() or non_empty_list(a)
So you should pass non-empty lists everywhere a list is expected. But you can’t pass a list where a non-empty one is expected.

But overall, you are right: our concern is exactly all of the extra function calls that may now suddenly become necessary (and the tension mentioned in the article). We will review our design decisions as we keep on rolling out the type system!

Re:Typing Lists and Tuples in Elixir by yawboakye on Wednesday August 28, 2024 @02:30PM (#41382653)
for when one expects a list to be non-empty, i think there’s strong argument in favor of an enforcement from the type checker, given that the prove will very likely be necessary. if not in the application code then in the tests.
Re:Typing Lists and Tuples in Elixir by greener_grass on Wednesday August 28, 2024 @02:51PM (#41382879)
Does this break down if we want some other types?

e.g.

    list(a) = empty_list() or singleton_list(a) or two_or_more_list(a)