Assuming M
is a Functor, mapply
in scalaz's Functor
has a similar type signature:
def mapply[A, B](a: A)(f: F[A => B]): F[B] = map(f)((ff: A => B) => ff(a))
So you could write transform in terms of that:
def transform[M[_],A,B](m: M[A => B])(implicit f:Functor[M]):A => M[B] = f.mapply(_)(m)
Edit: Another implementation using features from FunctorSyntax
:
def transform[M[_]:Functor,A,B](m: M[A => B]):A => M[B] = _.mapply(m)