     case .Cons(_, let tail): return tail.endIndex.successor()
     }
   }
+  
   public func with(val: Element, atIndex n: Int) -> List<Element> {
     switch (n, self) {
-    case (0, .Cons(_, let tail)):
-      return Cons(head: val, tail: tail)
-    case (_, .Cons(let head, let tail)):
-      return Cons(head: head, tail: tail.with(val, atIndex: n - 1))
+    case (0, .Cons(_, let tail)): return val |> tail
+    case (_, .Cons(let head, let tail)): return head |> tail.with(val, atIndex: n - 1)
     case (_, .Nil): fatalError("Index out of range")
     }
   }

  public func appended(with: Element) -> List<Element> {
    switch self {
    case .Nil: return [with]
    case .Cons(let head, let tail): return List.Cons(head: head, tail: tail.appended(with))
    }
  }
  public func extended(with: List<Element>) -> List<Element> {
    switch self {
    case .Nil: return with
    case .Cons(let head, let tail): return List.Cons(head: head, tail: tail.extended(with))
    }
  }
  public func extended<

}

extension List : ArrayLiteralConvertible {
  public init<G : GeneratorType where G.Element == Element>(var _ gen: G) {
    self = gen.next().map {.Cons(head: $0, tail: List(gen))} ?? .Nil
  }
  public init<S : SequenceType where S.Generator.Element == Element>(seq: S) {
    self = List(seq.generate())
  }
  public init(arrayLiteral: Element...) {
    self = List(arrayLiteral.generate())
  }
}

