 
   defp ensure_loaded(Elixir), do: { :error, :nofile }
   defp ensure_loaded(mod),    do: Code.ensure_compiled(mod)
+
+  ## Ad-hoc conversions
+
+  defp to_entries(Mod[name: name]) do
+    [name]
+  end
+
+  defp to_entries(Fun[name: name, arities: arities]) do
+    lc a inlist arities, do: "#{name}/#{a}"
+  end
+
+  defp to_uniq_entries(Mod[]) do
+    []
+  end
+
+  defp to_uniq_entries(Fun[] = fun) do
+    to_entries(fun)
+  end
+
+  defp to_hint(Mod[name: name], hint) do
+    :binary.part(name, size(hint), size(name)-size(hint)) <> "."
+  end
+
+  defp to_hint(Fun[name: name], hint) do
+    :binary.part(name, size(hint), size(name)-size(hint))
+  end
 end

    length = byte_size(hint)
    prefix = :binary.longest_common_prefix(binary)
    if prefix in [0, length] do
      entries = Enum.reduce(entries, [], fn e, acc -> Entry.to_entries(e) ++ acc end)
      yes("", entries)
    else
      yes(:binary.part(first.name, prefix, length-prefix), [])


  defrecord Mod, name: nil, type: nil
  defrecord Fun, name: nil, arities: []

  def expand([]) do
    funs = module_funs(IEx.Helpers) ++ module_funs(Kernel)
