Skip to content

@rampion /HigherOrderVsCurried.txt
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
When is a tuple not a tuple, and other scala type error ambiguities
scala> def k( j : (Int => Int) => Int ) : Int = j(_+1)
k: (j: Int => Int => Int)Int
scala> def p(q : Int => Int) : Int = q(0)
p: (q: Int => Int)Int
scala> def z = (x : Int) => (y : Int) => x + y
z: Int => Int => Int
scala> k(p)
res1: Int = 1
scala> k(z)
<console>:10: error: type mismatch;
found : Int => Int => Int
required: Int => Int => Int
k(z)
^
scala> def f(x : Int, y : Int) : Int = x + y
f: (x: Int, y: Int)Int
scala> def g(z : (Int, Int)) : Int = z._1 + z._2
g: (z: (Int, Int))Int
scala> def h(c : (Int, Int) => Int) : Int = c(1,2)
h: (c: (Int, Int) => Int)Int
scala> f(1,2)
res0: Int = 3
scala> g(1,2)
res1: Int = 3
scala> h(f)
res2: Int = 8
scala> h(g)
<console>:10: error: type mismatch;
found : (Int, Int) => Int
required: (Int, Int) => Int
h(g)
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.