Parameterized enumerated type in elixir types

Is it possible to parameterize the type Enumerable.t in elixir?

so I currently have a function that accepts a list of foo s:

 @spec the_awesome([foo]) :: any def the awesome(foos) do Enum.reduce(foos, &(bar(&2, &1))) end 

and indeed, this does not have to be a list! since the function call is only from the Enum module, I would like to change typepec to take any Enumerable, but keep the requirement that Enumerable consist entirely of foo s

Something like

 @spec the_awesome(Enumerable.t(foo)) :: any 

Is it possible?

+7
types elixir
source share
1 answer

Unfortunately, not now. We will need to teach the dialyzer how to handle the protocols if we really want them to be expressive, and there are no plans for that.

+4
source share

All Articles