   to the given function. Adds initial value if
   the key does not exist in the dicionary.
   """
+  @spec update(t, key :: term, initial :: term, (term -> term)) :: t
   def update(dict, key, initial, fun) when is_function(fun, 1) do
     { dict, _ } = dict_put(dict, key, { :update, initial, fun })
     dict

  @doc """
  Converts the dict to a list.
  """
  def to_list(ordered(bucket: bucket)) do
    bucket
  end

  Puts the given value under key in the dictionary
  only if one does not exist yet.
  """
  @spec put_new(t, key :: term, value :: term) :: t
  def put_new(dict, key, value) do
    update(dict, key, value, fn(v) -> v end)
  end
