         try do
           f1.(x, y)
         catch
-          { :stream_lazy, nesting, rest } ->
-            throw({ :stream_flat_map, nesting, rest })
+          { :stream_lazy, rest } ->
+            throw({ :stream_flat_map, rest })
         end
       end)
     catch
-      { :stream_flat_map, nesting, rest } ->
-        throw({ :stream_lazy, nesting, rest })
+      { :stream_flat_map, rest } ->
+        throw({ :stream_lazy, rest })
     end
   end
 


  """
  @spec map(Enumerable.t, (element -> any)) :: t
  def map(enumerable, f) do
    Lazy[enumerable: enumerable,
         fun: fn(f1) ->
           fn(entry, acc) ->
             f1.(f.(entry), acc)
           end
         end]
  end

  @doc """


  """
  @spec with_index(Enumerable.t) :: t
  def with_index(enum) do
    lazy enum, 0, fn(f1) ->
      fn(entry, [h,counter|t]) ->
        [h|t] = f1.({ entry, counter }, [h|t])
        [h,counter+1|t]
      end
    end
  end

  @compile { :inline, lazy: 2, lazy: 3 }

  defp lazy(enum, fun) do
    case enum do
      Lazy[funs: funs] = lazy ->
        lazy.funs([fun|funs])
      _ ->
        Lazy[enum: enum, funs: [fun], accs: []]
    end
  end

  defp lazy(enum, acc, fun) do
    case enum do
      Lazy[funs: funs, accs: accs] = lazy ->
        lazy.funs([fun|funs]).accs([acc|accs])
      _ ->
        Lazy[enum: enum, funs: [fun], accs: [acc]]
    end
  end
end
