I'm playing around with higher 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]
!"
Implicit arguments are arguments that occur in Logical Form, but are omitted in the syntax. Consider the following sentences: (1) Mary was run over by a car. (2) Mary was run over with a car. (21) implies that there is no perceivable or known agent.
The this variable is a product of C++'s member calling syntax. Instead of the programmer having to explicitly declare a parameter identifying the object (as in Ada), C++ does this automatically for you (this). In most implementations, C++ parameters are bound to offsets to locations on the stack or to registers.
Trial and error ;)
val pn5 = p2 _ compose pn3[Int]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With