// RUN: %target-run-simple-swift | FileCheck %s

func curry<T, U, V>(f: (T, U) -> V)(_ x: T)(_ y: U) -> V {
  return f(x, y)
}

let insult = curry(+)("I'm with stupid ☞ ")
println(insult("😡")) // CHECK: I'm with stupid ☞ 😡

let plus1 = curry(+)(1)
println(plus1(5)) // CHECK-NEXT: 6

let plus5 = curry(+)(5)
println(plus5(5)) // CHECK-NEXT: 10

println(insult("😰")) // CHECK-NEXT: I'm with stupid ☞ 😰

// rdar://problem/19195470

func pair<T,U> (a: T) -> U -> (T,U) {
	return { b in (a,b)	}
}

func pair_<T,U> (a: T)(b: U) -> (T,U) {
	return (a,b)
}

infix operator <+> { }
func <+><T,U,V> (lhs: T?, rhs: T -> U -> V) -> U -> V? {
	if let x = lhs {
		return rhs(x)
	} else {
		return { _ in nil }
	}
}

let a : Int? = 23
let b : Int? = 42
println((b <+> pair)(a!)) // CHECK-NEXT: (42, 23)
println((b <+> pair_)(a!)) // CHECK-NEXT: (42, 23)

// RUN: %target-run-simple-swift | FileCheck %s

func curry<T, U, V>(f: (T, U) -> V)(_ x: T)(_ y: U) -> V {
  return f(x, y)
}

let insult = curry(+)("I'm with stupid ☞ ")
println(insult("😡")) // CHECK: I'm with stupid ☞ 😡

let plus1 = curry(+)(1)
println(plus1(5)) // CHECK-NEXT: 6

let plus5 = curry(+)(5)
println(plus5(5)) // CHECK-NEXT: 10

println(insult("😰")) // CHECK-NEXT: I'm with stupid ☞ 😰

--- 
+++ 
@@ -14,3 +14,27 @@
 println(plus5(5)) // CHECK-NEXT: 10
 
 println(insult("😰")) // CHECK-NEXT: I'm with stupid ☞ 😰
+
+// rdar://problem/19195470
+
+func pair<T,U> (a: T) -> U -> (T,U) {
+	return { b in (a,b)	}
+}
+
+func pair_<T,U> (a: T)(b: U) -> (T,U) {
+	return (a,b)
+}
+
+infix operator <+> { }
+func <+><T,U,V> (lhs: T?, rhs: T -> U -> V) -> U -> V? {
+	if let x = lhs {
+		return rhs(x)
+	} else {
+		return { _ in nil }
+	}
+}
+
+let a : Int? = 23
+let b : Int? = 42
+println((b <+> pair)(a!)) // CHECK-NEXT: (42, 23)
+println((b <+> pair_)(a!)) // CHECK-NEXT: (42, 23)
Add test cases from rdar://problem/19195470.

Swift SVN r24549
