       _ -> lc arg inlist args, do: variable(arg)
     end
     spec = typespec(definition, (lc {:var, _, var} inlist args, do: var), caller)
-    vars = lc {:var, line, name} inlist args, do: (quote do: {:var, unquote(line), unquote(name)})
-    type = quote do: {unquote(name), unquote(spec), unquote(vars)}
+    vars = lc ({:var, _, _} = var) inlist args, do: var
+    type      = Macro.escape { name, spec, vars }
     type_attr = if options[:opaque], do: :opaque, else: :type
     quote do
       Module.add_attribute __MODULE__, unquote(type_attr), unquote(type)


  defmacro defspec({name, line, args},[{:do, returns}]) do
    spec = typespec({{:fun, line, args}, returns}, [], __CALLER__)
    code = quote do: {{unquote(name), unquote(length(args))}, [unquote(spec)]}
    quote do
      @__specs__ unquote(code)
      {:spec, unquote(code)}

  end

  defp typespec({:"{}", line, []}, _, _) do
     {:type, line, :tuple, :any}
  end

  defp typespec({:"{}", line, t}, vars, caller) when is_list(t) do
     {:type, line, :tuple, lc(e inlist t, do: typespec(e, vars, caller))}
  end

  defp typespec({:fun, line, arguments}, vars, caller) when is_list(arguments) do
