Swift higher order function (Church pair aka cons) with generic parameter types not accepting input parameter types
I was messing around with the functional programming in Swift 2.1, trying to implement the Church encoding pair/cons function ( cons = λx λy λf f x y in untyped lambda calculus ), which I had read couldn't be done in earlier versions of Swift. With generics it looks like func cons<S,T,U>(x:S,_ y:T) -> ((S,T) -> U) -> U { return { (f:((S,T) -> U)) -> U in return f(x,y)} } cons(1,2) //error: cannot invoke 'cons' with an argument list of type '(Int, Int)' //note: expected an argument list of type '(S, T)' which doesn't work, and gives an error I cannot understand (surely parameter list of type