Resurrect t/3 iex helper

Closes #627
This commit is contained in:
Yurii Rashkovskii
2012-11-07 04:38:11 -08:00
parent 1f56b673bd
commit aba27a27e3
+30 -1
View File
@@ -223,7 +223,21 @@ defmodule IEx.Helpers do
t(Enum)
"""
def t(module) do
defmacro t({ :/, _, [{ { :., _, [mod, fun] }, _, [] }, arity] }) do
quote do
t(unquote(mod), unquote(fun), unquote(arity))
end
end
defmacro t(module) do
quote do
t(unquote(module), :all)
end
end
@doc false
def t(module, :all) do
types = lc type inlist Kernel.Typespec.beam_types(module), do: print_type(type)
if types == [] do
@@ -233,6 +247,21 @@ defmodule IEx.Helpers do
:ok
end
@doc false
def t(module, type, arity) do
types = lc {_, {t, _, args}} = typespec inlist Kernel.Typespec.beam_types(module),
length(args) == arity and t == type, do: typespec
case types do
[] ->
IO.puts "No types for #{inspect module} has been found"
[type] ->
print_type(type)
end
:ok
end
@doc """
Prints all specs from a given module.