Hi Abdul
I suspect this may be more of a question for scala-user, but from a quick look, and without much investigation, it seems the problem is that the compiler interprets the expression accumulate[T, O, O](a => a)(to) as if you were trying to pass explicit arguments for the implicit parameters of the method accumulate. The method takes two implicit parameters, but the first argument list we are providing contains only one (a => a), so the compiler complains.
The following variants, which help the compiler understand that we are first trying to "create a version" of the accumulate method with the type parameters bound to T, O and O, then apply the arguments "a => a" and "to" to it, both work for me:
scala> def reduce[T[_]: Traversable, O: Monoid]: T[O] => O = to => {
| val accumulateFun: (O => O) => T[O] => O = accumulate _
| accumulateFun(a => a)(to)
| }
warning: there was one feature warning; re-run with -feature for details
reduce: [T[_], O](implicit evidence$1: Traversable[T], implicit evidence$2: Mono
id[O])T[O] => O
scala> def reduce[T[_]: Traversable, O: Monoid]: T[O] => O = to => accumulate[
T, O, O].apply(a => a)(to)
warning: there was one feature warning; re-run with -feature for details
reduce: [T[_], O](implicit evidence$1: Traversable[T], implicit evidence$2: Mono
id[O])T[O] => O
Note that both variants result in a warning on 2.11.6:
<console>:10: warning: higher-kinded type should be enabled
by making the implicit value scala.language.higherKinds visible.
This can be achieved by adding the import clause 'import scala.language.higherKi
nds'
or by setting the compiler option -language:higherKinds.
See the Scala docs for value scala.language.higherKinds for a discussion
why the feature should be explicitly enabled.
Regards
ap
On Saturday, 22 October 2016 15:31:24 UTC-4,