Skip to content

Instantly share code, notes, and snippets.

@Katrix
Created October 4, 2019 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Katrix/81f27774cf49de86b40391610b0a0902 to your computer and use it in GitHub Desktop.
Save Katrix/81f27774cf49de86b40391610b0a0902 to your computer and use it in GitHub Desktop.
object Minified {
trait Inspect[F[_[_]], In] {
type Out
}
object Inspect {
type Aux[F[_[_]], In, Out0] = Inspect[F, In] {
type Out = Out0
}
def apply[F[_[_]], In](
implicit findReplace: Inspect[F, In]
): Aux[F, In, findReplace.Out] = findReplace
implicit def valueTypes[F[_[_]], W[_]]: Inspect.Aux[F, F[W], W[Int]] =
new Inspect[F, F[W]] {
type Out = W[Int]
}
}
object Inspect2 {
def apply[F[_[_]], In] = new PartiallyApplied[F, In]
class PartiallyApplied[F[_[_]], In] {
def check[W[_]](implicit ev: In =:= F[W]): Int = 0
}
}
type F2[W[_]] = W[W[Int]]
//Doesn't work
Inspect[F2, Option[Option[Int]]]
//Works
Inspect2[F2, Option[Option[Int]]].check
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment