Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Last active January 2, 2016 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save markhibberd/8294295 to your computer and use it in GitHub Desktop.
Save markhibberd/8294295 to your computer and use it in GitHub Desktop.
object blah {
case class Id[+A](a: A)
object Id {
implicit def IdFunctor: Functor[Id] = ???
}
case class OptionT[F[+_], +A](x: F[Option[A]])
trait Functor[F[+_]]
object OptionT {
implicit def OptionTFunctor[F[+_]: Functor]: Functor[({ type l[+a] = OptionT[F, a] })#l] =
sys.error("todo")
}
case class Writer[+W, +A](w: W, a: A)
object Writer {
implicit def WriterFunctor[W]: Functor[({ type l[+a] = Writer[W, a] })#l] =
sys.error("todo")
}
type WWW[+A] = Writer[String, A]
type OOO[+A] = OptionT[WWW, A]
implicitly[Functor[WWW]]
implicitly[Functor[OOO]]
implicitly[Functor[({ type l[+a] = Writer[String, a] })#l]]
implicitly[Functor[({ type l[+a] = OptionT[ ({ type m[+b] = OptionT[Id, b] })#m, a] })#l]]
implicitly[Functor[({ type l[+a] = OptionT[ ({ type m[+b] = Writer[String, b] })#m, a] })#l]]
// implicitly[Functor[({ type l[+a] = OptionT[WWW, a] })#l]]
/*
blah.scala:19: error: could not find implicit value for parameter e: blah.Functor[[+a]blah.OptionT[[+A]blah.Writer[java.lang.String,A],a]]
implicitly[Functor[({ type l[+a] = OptionT[WWW, a] })#l]]
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment