 
   defrecord Mod, name: nil, type: nil
   defrecord Fun, name: nil, arities: []
-
-  defprotocol Entry do
-    @moduledoc false
-    def to_entries(entry)
-    def to_uniq_entries(entry)
-    def to_hint(entry, hint)
-  end
-
-  defimpl Entry, for: Mod do
-    @moduledoc false
-
-    def to_entries(mod) do
-      [mod.name]
-    end
-
-    def to_uniq_entries(_fun) do
-      []
-    end
-
-    def to_hint(Mod[name: name], hint) do
-      :binary.part(name, size(hint), size(name)-size(hint)) <> "."
-    end
-  end
-
-  defimpl Entry, for: Fun do
-    @moduledoc false
-
-    def to_entries(fun) do
-      lc a inlist fun.arities, do: "#{fun.name}/#{a}"
-    end
-
-    def to_uniq_entries(fun) do
-      to_entries(fun)
-    end
-
-    def to_hint(Fun[name: name], hint) do
-      :binary.part(name, size(hint), size(name)-size(hint))
-    end
-  end
 
   def expand([]) do
     funs = module_funs(IEx.Helpers) ++ module_funs(Kernel)


  defp ensure_loaded(Elixir), do: { :error, :nofile }
  defp ensure_loaded(mod),    do: Code.ensure_compiled(mod)
end

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