Skip to content

Instantly share code, notes, and snippets.

@travisbrown
Created November 22, 2012 14:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travisbrown/4131492 to your computer and use it in GitHub Desktop.
Save travisbrown/4131492 to your computer and use it in GitHub Desktop.
Weird view application observation
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