     code
   end
 
-  def defspec(_type, other, _caller) do
+  def defspec(_type, other, caller) do
     spec = Macro.to_string(other)
-    raise ArgumentError, message: "invalid function type specification #{spec}"
+    compile_error caller, "invalid function type specification #{spec}"
   end
 
   defp guard_to_constraints({ :is_subtype, meta, [{ name, _, _ }, type] }, caller) do

  end

  # Handle remote calls
  defp typespec({{:., meta, [remote, name]}, _, args}, vars, caller) do
    remote = Macro.expand remote, caller
    unless is_atom(remote), do: raise(ArgumentError, message: "invalid remote in typespec")
    remote_type({typespec(remote, vars, caller), meta, typespec(name, vars, caller), args}, vars, caller)
  end


    do_deftype(kind, type, { :term, [line: caller.line], nil }, caller)
  end

  def deftype(_kind, other, caller) do
    type_spec = Macro.to_string(other)
    compile_error caller, "invalid type specification #{type_spec}"
  end

  defp do_deftype(kind, { name, _, args }, definition, caller) do
