Created
July 20, 2012 05:08
-
-
Save tonymorris/3148800 to your computer and use it in GitHub Desktop.
WTF?
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
trait Functor[F[_]] | |
object Functor { | |
implicit val OptionFunctor: Functor[Option] = | |
error("") | |
} | |
case class OptionT[F[+_], +A] | |
object OptionT { | |
implicit def OptionTFunctor[F[+_]](implicit F0: Functor[F]): Functor[({type λ[α] = OptionT[F, α]})#λ] = | |
error("") | |
} | |
trait TTT { | |
// fine | |
val a = implicitly[Functor[Option]] | |
// fine | |
val b = implicitly[Functor[({type lam[+a]=OptionT[Option, a]})#lam]] | |
// not fine | |
val c = implicitly[Functor[({type lam[+a]=OptionT[({type l[+b]=OptionT[Option, b]})#l, a]})#lam]] | |
} | |
Thanks Jason, but why would out work with a type alias and not type lambda
inline? I struggle to how it would affect inferencing. I guess I can find
out with the compiler flag, thanks.
…On Jul 21, 2012 7:09 AM, "Jason Zaugg" < ***@***.***> wrote:
BTW, `-Yinfer-debug` is your friend at times like these.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/3148800
Oh, I missed the key point of your example. It's an interesting one. A bit of a closer look at it:
case class Wibb[A]
trait Functor[F[_]]
object TTT {
implicit val WibbFunctor: Functor[Wibb] =
error("")
implicit def OptionTFunctor[F[_]](implicit F0: Functor[F]): Functor[({type λ[α] = OptionT[F, α]})#λ] =
error("")
type Q[A] = OptionT[Wibb, A]
type R[A] = OptionT[Q, A]
type S[A] = OptionT[({type l[b]=OptionT[Wibb, b]})#l, A]
// okay
OptionTFunctor[({type l[b]=OptionT[Wibb, b]})#l](OptionTFunctor[Wibb](WibbFunctor)): Functor[S]
OptionTFunctor[Q](OptionTFunctor(WibbFunctor)): Functor[R]
implicitly[Functor[R]] // Infers [Q] !
// a bridge too far
// OptionTFunctor(OptionTFunctor[Wibb](WibbFunctor)): Functor[S]
// Can't infer [Q]
// OptionTFunctor(OptionTFunctor(WibbFunctor)): Functor[R]
}
Yeah, that's exactly the point. I will hopefully take a look at it closely soon.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BTW,
-Yinfer-debug
is your friend at times like these.