I'm playing around with hi开发者_StackOverflowgher kinds, and I'm trying to use compose. I've got the following code:
def p2( a : Int) = a + 2
def p3( a : Int) = a + 3
val p5 = p2 _ compose p3
def pn3[T](n : T)(implicit ev : Numeric[T]) = ev.plus(n, ev.fromInt(3))
val pn5 = p2 _ compose pn3
It all works until the last line:
error: could not find implicit value for parameter ev: Numeric[T]
Which makes sense but how do I tell it, "I want Numeric[Int]
!"
Trial and error ;)
val pn5 = p2 _ compose pn3[Int]
精彩评论