This is a follow-up to my previous question
I would like to generalize the implicit conversion toApplicative
, which adds method <*>
to any M[A=>B]
, where M
is Applicative
(i.e. there is a typeclass instance Applicative[M]
)
implicit def toApplicative[M[_], A, B](mf: M[A=>B])(implicit apm: Applicative[M]) =
new { def<*>(ma: M[A]) = apm.ap(ma)(mf) }
Unfortunately I have got an error:
<console>:25: error: Parameter type in structural refinement
may not refer to an abstract type defined outside that refinement
How would you suggest implement such an implicit conversion ?