Created
November 22, 2012 14:39
-
-
Save travisbrown/4131492 to your computer and use it in GitHub Desktop.
Weird view application observation
This file contains 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
import scalaz._ | |
import scalaz.std.option._ | |
import scalaz.syntax.functor._ | |
trait Inc extends (Int => Int) { | |
implicit def incToLiftable(i: this.type): { | |
def lift(implicit F: Functor[Option]): Option[Int] => Option[Int] | |
} = implicitly[this.type => LiftV[Option, Int, Int]].apply(i) | |
def apply(x: Int) = x + 1 | |
} | |
object inc1 extends Inc | |
object inc2 extends Inc { def lift = throw new Exception("I'm fake!") } | |
// Works perfectly: | |
inc2 lift implicitly[Functor[Option]] | |
// But the other doesn't: | |
// scala> inc1 lift implicitly[Functor[Option]] | |
// <console>:19: error: type mismatch; | |
// found : scalaz.Functor[Option] | |
// required: scalaz.Functor[F] | |
// inc1 lift implicitly[Functor[Option]] | |
// ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment