Hi i am starsting to learn Scalaz.
I want to get a function and map over it with another function.
although i am able to write this:
import scalaz._, Scalaz._
import std.function._
import syntax.monad._
((x: Int) => x + 1) map {_ * 7}
and it works, when i use the explicit appraoch as per the examples in github project it does not work (see below)
import scalaz._, Scalaz._
import std.option._
import std.function._
import syntax.monad._
Functor[Function1[Int,Int]].map{x:Int => x * 4}{(x:Int) =>x * 7}
I get as error
Error:(10, 17) Function1 takes two type parameters, expected: one Functor[Function1].map{x:Int => x * 4}{(x:Int) =>x * 7}
I did inspired myself from an example in the doc that works
Functor[Option].map(Some("adsf"))(_.length)
Expanding implicits of
((x: Int) => x * 4) map ((x: Int) => x * 7)we getSignature of
function1Covariantiswhilst signature of Functor.apply is
Substituting
F[_]with({type F[B] = Int => B})#F, or usingkind-projectorwithInt => ?, we makeapplyrequire implicitwhich is satisfied by
function1Covariant[Int]: Monad[Int => ?]sinceMonadis a type ofFunctor. Thus we could write explicitlyor using kind-projector as