是否可以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)
这可能吗?