elixir typespecs中参数化的可枚举类型

jis*_*one 8 types elixir

是否可以Enumerable.t在elixir中参数化类型?

所以目前我有一个带有foos 列表的函数:

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

而且它真的不一定是一个清单!因为唯一的函数调用来自Enum模块我想更改typespec以获取任何Enumerable,但保持Enumerable必须完全由foos 组成的要求

就像是

@spec the_awesome(Enumerable.t(foo)) :: any
Run Code Online (Sandbox Code Playgroud)

这可能吗?

Jos*_*lim 4

不幸的是现在还不行。如果我们真的希望透析器具有表达能力,那么我们需要教会透析器如何处理协议,但目前还没有这样做的计划。