Last active
August 29, 2015 14:00
-
-
Save pedrofurla/11244893 to your computer and use it in GitHub Desktop.
Get implicit resolution out of the companion object. Why not happening. See bottom of the file for error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Other2 { | |
import scalaz._ | |
import Scalaz._ | |
import scalaz.syntax._ | |
case class ElapsedTime[A](time: A) | |
object ElapsedTime { | |
type O[CC[_]] = { | |
type λ[A]=ElapsedTime[CC[A]] | |
} | |
implicit def isFunctor_CC[CC[_]](implicit evf: Functor[CC]) = new Functor[O[CC]#λ] { | |
def map[A,B](fa: ElapsedTime[CC[A]])(f: A => B): ElapsedTime[CC[B]] = ElapsedTime[CC[B]](evf.map(fa.time)(f)) //fa.time.map(f) | |
} | |
// implicit def unapplyMA[TC[_[_]], M0[_], A0](implicit TC0: TC[M0]): Unapply[TC, M0[A0]] { | |
//implicit def unapplyFunctorEt[TC[_[_]],CC[_], A0](implicit TC0: TC[O[CC]#λ]) = Unapply.unapplyMA[TC, O[CC]#λ, A0] | |
// above doesn't seem to have any effect | |
implicit def toFunctorOps[A](et:ElapsedTime[NonEmptyList[A]]): FunctorOps[O[NonEmptyList]#λ, A] = | |
implicitly[Functor[O[NonEmptyList]#λ]].functorSyntax.ToFunctorOps(et) | |
implicitly[Functor[O[NonEmptyList]#λ]] | |
ElapsedTime(NonEmptyList.nels(1L,2L,3L)).map{_ + 1 } // works only if toFunctorOps is defined | |
} | |
ElapsedTime(NonEmptyList.nels(1L,2L,3L)).map{_ + 1 } // Map is not a member of | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment