 print("")
 
 func isPalindrome0<
-  S : Collection
-  where
-  S.Index : BidirectionalIndex,
-  S.Iterator.Element : Equatable
+  S : BidirectionalCollection
+  where
+  S.Iterator.Element : Equatable,
+  S.Indices.Iterator.Element == S.Index
 >(seq: S) -> Bool {
   typealias Index = S.Index
 
   let a = seq.indices
-  var i = seq.indices
-  var ir = i.lazy.reversed()
+  let i = seq.indices
+  let ir = i.lazy.reversed()
   var b = ir.makeIterator()
   for i in a {
     if seq[i] != seq[b.next()!] {

print(isPalindrome2(X("Zerimar-O-ramireZ")))

func isPalindrome4<
  S: Collection
  where
  S.Index : BidirectionalIndex,
  S.Iterator.Element : Equatable
>(seq: S) -> Bool {
  typealias Index = S.Index

  var a = PermutationGenerator(elements: seq, indices: seq.indices)
  // FIXME: separate ri from the expression below pending
  // <rdar://problem/15772601> Type checking failure
  var i = seq.indices
  let ri = i.lazy.reversed()
  var b = PermutationGenerator(elements: seq, indices: ri)
  for nextChar in a {

  }
  subscript(i: Index) -> Element { return msg[i] }
  func next(i: Index) -> Index { return msg.next(i) }
  func previous(i: Index) -> Index { return msg.previous(i) }
}

var foobar = X("foobar")
